Fixed #25324 -- Registered ModelAdmin instances with @admin.register decorator

This commit is contained in:
Y3K 2015-08-30 19:00:39 -05:00 committed by Markus Holtermann
parent cbcf78fa94
commit 235caabacc
4 changed files with 5 additions and 9 deletions

View File

@ -24,6 +24,7 @@ csrf_protect_m = method_decorator(csrf_protect)
sensitive_post_parameters_m = method_decorator(sensitive_post_parameters())
@admin.register(Group)
class GroupAdmin(admin.ModelAdmin):
search_fields = ('name',)
ordering = ('name',)
@ -39,6 +40,7 @@ class GroupAdmin(admin.ModelAdmin):
db_field, request=request, **kwargs)
@admin.register(User)
class UserAdmin(admin.ModelAdmin):
add_form_template = 'admin/auth/user/add_form.html'
change_user_password_template = None
@ -196,6 +198,3 @@ class UserAdmin(admin.ModelAdmin):
request.POST['_continue'] = 1
return super(UserAdmin, self).response_add(request, obj,
post_url_continue)
admin.site.register(Group, GroupAdmin)
admin.site.register(User, UserAdmin)

View File

@ -4,6 +4,7 @@ from django.contrib.flatpages.models import FlatPage
from django.utils.translation import ugettext_lazy as _
@admin.register(FlatPage)
class FlatPageAdmin(admin.ModelAdmin):
form = FlatpageForm
fieldsets = (
@ -16,5 +17,3 @@ class FlatPageAdmin(admin.ModelAdmin):
list_display = ('url', 'title')
list_filter = ('sites', 'registration_required')
search_fields = ('url', 'title')
admin.site.register(FlatPage, FlatPageAdmin)

View File

@ -2,10 +2,9 @@ from django.contrib import admin
from django.contrib.redirects.models import Redirect
@admin.register(Redirect)
class RedirectAdmin(admin.ModelAdmin):
list_display = ('old_path', 'new_path')
list_filter = ('site',)
search_fields = ('old_path', 'new_path')
radio_fields = {'site': admin.VERTICAL}
admin.site.register(Redirect, RedirectAdmin)

View File

@ -2,8 +2,7 @@ from django.contrib import admin
from django.contrib.sites.models import Site
@admin.register(Site)
class SiteAdmin(admin.ModelAdmin):
list_display = ('domain', 'name')
search_fields = ('domain', 'name')
admin.site.register(Site, SiteAdmin)