I have different types of users and have created models for each user type.signup is different for everyone.. now i want to select models at signup page according to user choices or type. for example if someone selects student then a signup page with different form fields should appear.like that i have to do for each user type.is it possible to go by the choice option with if else method inside a class and choosing the different user models according to choices??
Asked
Active
Viewed 188 times
1 Answers
0
It's not clear whether your user classes share a common base class, but I think that would be essential. The documentation has a lot of information about using a custom user model. But, I recommend reading this post, and going with Option 2: Using One-To-One Link With a User Model (Profile)
What is a One-To-One Link? It is a regular Django model that’s gonna have it’s own database table and will hold a One-To-One relationship with the existing User Model through a OneToOneField.
When should I use a One-To-One Link? You should use a One-To-One Link when you need to store extra information about the existing User Model that’s not related to the authentication process. We usually call it a User Profile.

Mark Bailey
- 1,617
- 1
- 7
- 13
-
what i need is to select a class based on type of user.like if selected choice is student then student class should appear.how to implement this inside our models.py?? – Amit Kumar Apr 17 '19 at 16:29
-
It's hard to be sure without knowing all the details, but I think you are probably best to stick with a very simple User class that is used by Django Auth, then for your specific functionality create a Student class with a foreign key or one-to-one relationship to User. – Mark Bailey Apr 18 '19 at 15:18
-
How about creating an app for every user type and creating user models over there??because i will have different functionalities for each user type... – Amit Kumar Apr 18 '19 at 22:07