python - Working with user roles in Django -


i have question in project have need of work users of 3 (may more) types of them have different roles: physician patient administrator

i have been thinking use of django model users , extend creating userprofile model ... ignore how manage different roles because, userprofile model have fields of user model, althought don't know how address roles topic.

1 user have many userprofiles may be? don't know

or may should create roles model/table in specify roles types , create relation users model. possibility.

another possibility (as comment more below) check django permissions system, in can create user groups, , assign permissions these groups, althought here can edit, create , delete models really?

i few confuse of how address subject

searching found app. https://github.com/dabapps/django-user-roles

if can orient me it, grateful best regards

you work django's built in permissions

that may more need though. simple solution userprofile model role field onetoonefield user:

class userprofile(models.model):   user = models.onetoonefield(user, related_name="profile")   role = models.charfield() 

set roles , checks roles in views:

user.profile.role = "physician" user.profile.save()  if user.profile.role == "physician":   #do physician case here 

Comments

Popular posts from this blog

java - Static nested class instance -

c# - Bluetooth LE CanUpdate Characteristic property -

JavaScript - Replace variable from string in all occurrences -