Add basic login.
[wolnelektury.git] / src / redirects / admin.py
1 from django.contrib import admin
2 from django.contrib.sites.models import Site
3 from . import models
4
5
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']
10
11     def full_url(self, obj):
12         if not obj.slug:
13             return None
14         site = Site.objects.get_current()
15         url = obj.get_absolute_url()
16         return f'https://{site.domain}{url}'
17
18
19 admin.site.register(models.Redirect, RedirectAdmin)