sanders
sanders

Reputation: 133

multiple users and Django

Starting to learn Django, not sure how to deal with multiple users and user types. What I would like to do is have a signin page where users of type A, B or C can log in (or new users can register as type A or B) and depending on their type they are presented with a different site. Furthermore, users of types A and B can actually be organized in groups within their own type and across types. So B1 and B2 may be only assigned to A1 or a group 'GA' which contains members {A2, A1, A3}.

The main goal is to create a site where people can posts question to specific experts or to the general public. When the experts log in they would only be presented to the users assigned to them and if they don't know the answer they could contact other experts or pass the question on to a larger group of experts say GE = {E1, E3, E6}.

There may already be tool out there to do this and I am complete oblivious to it. As of now we're just going to write it from scratch, and Django seemed like a good tool to use.

Any suggestions are helpful.

Upvotes: 2

Views: 117

Answers (2)

killua8p
killua8p

Reputation: 314

It sounds to me that you are building something like a task management system. Where questions are like tasks, and the experts are like the assignees of tasks.

There are two approaches.

APPROACH 1 - use the django authentication system

  1. Suppose you already know how to create users, authenticate them and log them in.

  2. Create user groups and assign permissions to each group (You could either do this through the django admin or through code)

  3. In the views.py, output different contents based on the permission that the logged in user has.

APPROACH 2 - custom build it

  1. Create a Model for User Type and a Model for User (you can either use the default User model or extend it)

  2. Assign each question to a specific User Type.

  3. In the views.py, determine what questions to display based on the User Type of the logged in User.

APPROACH 2 is recommended because it's more flexible and scalable, given that you will extend your programme with more functions in the future.

I think you should have the basic ideas to start with it. Good luck.

Upvotes: 1

awwester
awwester

Reputation: 10182

Sounds like quite the task you have! The first step is to use a Custom User Model, which will take the built-in django user model and allow you to extend it flexibly. I would suggest extending from the AbstractUser.

When you have your user authentication working you can add fields to the users to categorize them how you want.

Your explanation of what you're trying to do after that in the view logic is a little confusing so I'm going to let you figure that part out, but building a custom user model should get you going in the right direction.

Upvotes: 1

Related Questions