1 from django.contrib import admin
2 from django.contrib.sites.models import Site
6 class RedirectAdmin(admin.ModelAdmin):
7 list_display = ['slug', 'url', 'counter', 'created_at', 'full_url']
8 readonly_fields = ['counter', 'created_at', 'full_url']
9 fields = ['slug', 'url', 'counter', 'created_at', 'full_url']
11 def full_url(self, obj):
14 site = Site.objects.get_current()
15 url = obj.get_absolute_url()
16 return f'https://{site.domain}{url}'
19 admin.site.register(models.Redirect, RedirectAdmin)