admin.py 765 Bytes
Newer Older
1
# Django Imports
2
from django.contrib import admin
3
4
from django.contrib.auth.admin import UserAdmin
from django.contrib.auth.models import User
5
# App Imports
6
from go.models import URL, RegisteredUser
7

8
# Define what attributes display in the URL Admin
9
10
11
class URLAdmin(admin.ModelAdmin):
    list_display = ("target", "short", "owner", "clicks", "date_created", "expires")

12
13
14
15
# Define an inline admin descriptor for User model
class RegisteredUserInline(admin.StackedInline):
  model = RegisteredUser
  can_delete = False
16

17
18
19
# Define a new User admin
class UserAdmin(UserAdmin):
  inlines = (RegisteredUserInline, )
20

21
# Register URLAdmin and modify User to use new UserAdmin
22
admin.site.register(URL, URLAdmin)
23
24
admin.site.unregister(User)
admin.site.register(User, UserAdmin)