I'm a bit unsure what to use Django user groups for.
我有点不确定如何使用Django用户组。
I have an application where every user belongs to a different organisation. The organisations don't have anything to do with read/write permissions. It's just a way to separate groups of users. Every organisation needs some additional fields, like a name, URL, and email address. New organisations will be added to the system over time. Within every organisation, users can have different permissions for moderation and administration, for which I (also) want to use user groups.
我有一个应用程序,每个用户都属于不同的组织。这些组织与读/写权限无关。这只是一种分离用户组的方法。每个组织都需要一些其他字段,例如名称,URL和电子邮件地址。随着时间的推移,新组织将被添加到系统中。在每个组织中,用户可以拥有不同的审核和管理权限,我(也)想要使用用户组。
My question: Should I use Django's user groups to define the organisations, or should I just make an 'Organisation' model with a relation to the user?
我的问题:我应该使用Django的用户组来定义组织,还是应该创建一个与用户关系的“组织”模型?
2 个解决方案
#1
1
Nope. User groups are made for different reasons. You CAN use them to define organisations but I think you should think bit further ahead:
不。用户组是出于不同原因而制作的。您可以使用它们来定义组织,但我认为您应该进一步思考:
- will the organisation require more fields than just name?
- perhaps you will need permissions in the future to define users roles within organisations?
该组织是否需要更多的字段而不仅仅是名称?
也许您将来需要权限来定义组织内的用户角色?
I'm sure you can come up with more things to think of. But if you answered yes to one of those questions then just create your Organisation model.
我相信你能想出更多值得思考的东西。但如果您对其中一个问题的回答是肯定的,那么只需创建您的组织模型即可。
#2
-1
1) You need to add group
from django admin
side under group
table.
1)您需要在组表下的django admin端添加组。
2) And while creating new user, assign specific group
to user
using user_obj.groups.add(group_id)
. Or Let user select group
at frontend.
2)在创建新用户时,使用user_obj.groups.add(group_id)将特定组分配给用户。或者让用户在前端选择组。
and then user_obj.save()
然后是user_obj.save()
in Group
table, you can create organization
在组表中,您可以创建组织
OR
You can create individual organization
table and assign assign user to specific organization.
您可以创建单个组织表并将用户分配给特定组织。
#1
1
Nope. User groups are made for different reasons. You CAN use them to define organisations but I think you should think bit further ahead:
不。用户组是出于不同原因而制作的。您可以使用它们来定义组织,但我认为您应该进一步思考:
- will the organisation require more fields than just name?
- perhaps you will need permissions in the future to define users roles within organisations?
该组织是否需要更多的字段而不仅仅是名称?
也许您将来需要权限来定义组织内的用户角色?
I'm sure you can come up with more things to think of. But if you answered yes to one of those questions then just create your Organisation model.
我相信你能想出更多值得思考的东西。但如果您对其中一个问题的回答是肯定的,那么只需创建您的组织模型即可。
#2
-1
1) You need to add group
from django admin
side under group
table.
1)您需要在组表下的django admin端添加组。
2) And while creating new user, assign specific group
to user
using user_obj.groups.add(group_id)
. Or Let user select group
at frontend.
2)在创建新用户时,使用user_obj.groups.add(group_id)将特定组分配给用户。或者让用户在前端选择组。
and then user_obj.save()
然后是user_obj.save()
in Group
table, you can create organization
在组表中,您可以创建组织
OR
You can create individual organization
table and assign assign user to specific organization.
您可以创建单个组织表并将用户分配给特定组织。