django中不同用户类型的“admin”接口 [英] seperate 'admin' interfaces for different user types in django

查看:411
本文介绍了django中不同用户类型的“admin”接口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



(只是缩写和粗略模式的一个例子)

我最近正在尝试创建一个具有多个用户级别的项目。


  • 我(超级用户)

    • 客户

      • 客户

      • 调查收藏

        • SurveyUser

          • Invitee


        • 调查

          • Invitee (被邀请者是调查和用户的孩子)


        • 问题

        • 等等






我最理想的是:


  • www.example.com/client/转到客户端界面,您必须是客户端才能访问

  • www.example.com/customer/转到客户界面,您必须成为客户才能访问



我已经建立对于所有这些使用定制的Django管理界面可能是不可能的(或是吗?)。因此,我倾向于为每个级别的用户手动创建管理员界面,允许他们管理他们各自的角色。对于每个人来说,拥有不同用户类型和单独接口的最佳方式是什么?



我喜欢继承用户的方式:
http://scottbarnham.com/blog/2008/ 08/21 / extend-the-django-user-model-with-inheritance /



但不确定我将如何设置不同的管理员区域为不同用户。



作为相关的一个侧面问题,我也不确定如何访问标准用户属性以及如何在ACTUAL管理界面中编辑/保存自定义属性我将使用。



我需要根据客户端数据库验证客户用户,以检查它们是客户端,但也可以针对管理身份验证的用户数据库进行身份验证,用户名,密码等。



我正在从PHP切换到Python / Django,所以任何建议都非常感谢帮助我。



谢谢!

解决方案

最接近我的是基于另一个stackoverflow文章:如何在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 stackoverflow 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.

这篇关于django中不同用户类型的“admin”接口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆