Install django-guardian
This commit is contained in:
parent
5f8d142508
commit
94931900e5
@ -44,6 +44,7 @@ ALLOWED_HOSTS = []
|
|||||||
|
|
||||||
AUTHENTICATION_BACKENDS = (
|
AUTHENTICATION_BACKENDS = (
|
||||||
'LandingPage.backends.OAuthBackend',
|
'LandingPage.backends.OAuthBackend',
|
||||||
|
'guardian.backends.ObjectPermissionBackend',
|
||||||
'django.contrib.auth.backends.ModelBackend',
|
'django.contrib.auth.backends.ModelBackend',
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -59,6 +60,7 @@ INSTALLED_APPS = [
|
|||||||
'django.contrib.sessions',
|
'django.contrib.sessions',
|
||||||
'django.contrib.messages',
|
'django.contrib.messages',
|
||||||
'django.contrib.staticfiles',
|
'django.contrib.staticfiles',
|
||||||
|
'guardian',
|
||||||
]
|
]
|
||||||
|
|
||||||
MIDDLEWARE = [
|
MIDDLEWARE = [
|
||||||
|
@ -3,6 +3,8 @@ from django.contrib.auth.admin import UserAdmin
|
|||||||
from .models import *
|
from .models import *
|
||||||
from .forms import SpecialUserChangeForm
|
from .forms import SpecialUserChangeForm
|
||||||
|
|
||||||
|
from guardian.admin import GuardedModelAdmin
|
||||||
|
|
||||||
class SpecialUserAdmin(UserAdmin):
|
class SpecialUserAdmin(UserAdmin):
|
||||||
form = SpecialUserChangeForm
|
form = SpecialUserChangeForm
|
||||||
|
|
||||||
@ -10,8 +12,11 @@ class SpecialUserAdmin(UserAdmin):
|
|||||||
(None, {'fields': ('display_name',)}),
|
(None, {'fields': ('display_name',)}),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
class ShowAdmin(GuardedModelAdmin):
|
||||||
|
pass
|
||||||
|
|
||||||
# Register your models here.
|
# Register your models here.
|
||||||
admin.site.register(Show)
|
admin.site.register(Show, ShowAdmin)
|
||||||
admin.site.register(User, SpecialUserAdmin)
|
admin.site.register(User, SpecialUserAdmin)
|
||||||
admin.site.register(Ban)
|
admin.site.register(Ban)
|
||||||
admin.site.register(ShowModerator)
|
admin.site.register(ShowModerator)
|
||||||
|
@ -2,3 +2,4 @@ Django==1.11.4
|
|||||||
Pillow==4.2.1
|
Pillow==4.2.1
|
||||||
dj-database-url==0.4.2
|
dj-database-url==0.4.2
|
||||||
requests==2.18.4
|
requests==2.18.4
|
||||||
|
django-guardian==1.4.9
|
||||||
|
Reference in New Issue
Block a user