My project need an admin for staff and a normal website for normal user. 
Staff can only login to staffsite and normal user can only login to 
website. Staff will login to admin to do some management. They can 
view normal user list and detail and create or delete normal user 
admin. The two type of user is very different, so I want to write a model 
for each of them, instead of using is_staff flag. But in a project, I can 
only have a USER_AUTH_MODEL. Is there a good way to implement these 
requirements?

Since a project can only have a USER_AUTH_MODEL, I separate the two type of 
user in two project (staffsite and website).
My currently design and implementation is as follow:

I wrote a standalone django app called member, and implement Member model

class Member(AbstractBaseUser):
    #member related fields

then I create two project “staffsite" and “website". “staffsite" is for 
internal use, “website" is open for normal user. “staffsite" just use the 
django built in auth.User. Member model in “staffsite" is just a normal 
model. “website" use Member model as USER_AUTH_MODEL.
I have two database, one for “staffsite" and one for “website". Since 
“staffsite" need to access Member’s data, so I implement a db router for 
“staffsite". Whenever I need to access Member’s data in 
“staffsite", router will route me to the correct db (You can say that I use 
db to link “staffsite” and “website” together.)
  member app need to install in both “staffsite" and “website", so I will 
have two copy of member app. This is not good for maintenance. Whenever I 
change the code in member app, I need to copy and paste to another one. I 
extract member app and create a standalone app, and after that I can use 
pip install -e  to install member app for both project and I only have to 
keep one copy of code.

This design is work, but I want to know whether there is a better way to 
meet the requirements. 

-- 
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+unsubscr...@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/5ab3b285-6bf5-40cb-9f3f-4fb7bad5c538%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to