且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

django中不同用户类型的“admin”接口

更新时间:2023-12-04 19:30:46

最接近我的是基于另一个***文章:如何在Django项目中拥有2个不同的管理网站?



我最终创建了两个完全独立的django.contrib.admin.sites.AdminSite实例,它们似乎d到最后工作,虽然不太理想。


I have recently being trying to create a project which has several levels of user involved.

(Just an example of an abbreviated and rough schema)

  • ME (Super User)
    • Client(s)
      • Customer(s)
      • Survey Collections
        • SurveyUser(s)
          • Invitee(s)
        • Surveys
          • Invitee(s) (invitee is a child of both survey and user)
        • Questions
        • Etc

I would ideally have:

  • www.example.com/client/ go to a client interface which you had to be a client to access
  • www.example.com/customer/ go to a customer interface which you had to be a customer to access

I have already established that using a customised Django admin interface for all of them is probably not going to be possible (or is it?). I am therefore leaning towards manually creating 'admin' interfaces for each level of user, allowing them to manage their respective roles. What is the best way of having different user types and separate interfaces for each one?

I like the way of inheriting users outlined at: http://scottbarnham.com/blog/2008/08/21/extending-the-django-user-model-with-inheritance/

But am unsure how I would set up different 'admin' areas for different users.

As a side issue that is related, I am also unsure of how to access the custom properties alongside standard user properties and how to edit/save them in the ACTUAL admin interface that I will use.

I would need to authenticate 'Client' users against a client database to check they are clients but somehow also authenticate against the user database which manages authentication, username, password etc.

I am switching from PHP to Python/Django so any advice greatly appreciated to help me along.

Thanks!

The closest I got to this was based on another *** article here: How to have 2 different admin sites in a Django project?

I ended up creating two entirely separate instances of django.contrib.admin.sites.AdminSite which seemed to work in the end, albeit not ideal.