Thursday, September 17, 2015

Re: Django models relation about user user_group asset asset group

I think you shoud use ForeignKey.

2015-09-17 23:49 GMT+08:00 周建华 <lastimac@gmail.com>:
I have design the base model like this:

class User
    some user attr

class UserGroup 
    some user_group attr

class Asset
   ...

class AssetGroup
   ...


I want to authorize asset and asset_group to user or user_group, I have no good idea about the models design

If i set like this:

class UserAsset
    user = ..
    asset = ...

class UserAssetGroup
   user = ..
   asset_group = ...

class UserGroupAsset
   user_group = 
   asset = 

class UserGroupAssetGroup
    user_group = 
    asset_group = ..


If I check the user  have the asset permission or not , i will check the user or user group of the user isn't have the asset permission,  the user or user group have the asset group(the asset belong to)  permission   . It's will check more than 10 tables.





--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/9444a015-85d0-43d3-972d-cd07cda5617c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CA%2B7P_%2Bsd50Kh-ycRY%3DqFtYBbiw4anOSrWMMqpbo2OvH23F8GHw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment