开发者

django application with multiple sites - how to restrict access for staff

I made a django application recently with multiple settings files, each setting file has its own SITE_ID and each SITE_ID is associated with site_id from the django_site table. Now, I want to create staff for certain 开发者_运维技巧sites only and other admins for all sites, how would I do something like that?

best wishes,


Mo - not sure whether you're still looking for an answer for this but this cross-post could be along the lines of what you're looking for.


I'm afraid I have bad news for you, you'll have to implement it on your own. What can you do is to implement a new class say SiteUsers, it can look as follows:

class SiteUsers(models.Model):
    site = models.ForeignKey(Site)
    users = models.ForeignKey(User)

then you can use a kind of user_passes_test decorator to force access control. I'm not aware of any ready to use solution.

another option would be to use groups. create set of groups for each site and sort users to those groups. I think you'll have to have groups like: site_1_add, site_1_delete, site_1_.... site_2_add, site_2_delete, site_2_....

however I'm afraid it does not scale so well. you will not find out unless you'll try.

anyway going either way will require a lot of admin customization. I really would need to do some research myself first.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜