本文介绍了如何在django自定义管理页面中添加默认添加用户页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用django的默认管理页面:

  urlpatterns = patterns('',
(r' admin /',include(django.contrib.admin.site.urls)),

添加用户页面看起来很像这样...



但是当我使用我自己的:

  urlpatterns = patterns('', 
url(r'^ admin /',include(admin.stripe_admin_site.urls)),


class StripeAdminSite(admin.AdminSite):
def index (self,request,extra_context = None):
return todo

注册到网站

  stripe_admin_site.register(User)

我得到这个


现在我怎么能让它看起来像是默认的,很容易?

解决方案

只需使用相同的



django.contrib.auth.admin import UserAdmin
stripe_admin_site.register(User,UserAdmin)
  p> 

When I use django's default admin page:

urlpatterns = patterns('',
     (r'^admin/', include(django.contrib.admin.site.urls)),
)

The add user page looks pretty like this...

But when I use my own:

urlpatterns = patterns('',
     url(r'^admin/', include(admin.stripe_admin_site.urls)),
)

class StripeAdminSite(admin.AdminSite):
    def index(self, request, extra_context=None):
          return todo

and

registered to the site

stripe_admin_site.register(User)

I got this

Now how can I make it look like the default, easily?

解决方案

Simply register the User model with the same ModelAdmin that Django uses by default:

from django.contrib.auth.admin import UserAdmin
stripe_admin_site.register(User, UserAdmin)

这篇关于如何在django自定义管理页面中添加默认添加用户页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-22 18:43