Reputation: 41
I want to create a web app in which I will have two different types of users Employee and Employers. They'll have mostly non common fields.How to implement separate registration of both. Currently I have inherited from the User model.
class Category(models.Model):
cname=models.CharField(max_length=250)
def __str__(self):
return self.cname
class Workplace(User):
address=models.TextField(max_length=250)
logo=models.ImageField(upload_to=upload_location,null=True,blank=True)
wcategory=models.ForeignKey(Category,on_delete=models.CASCADE)
class Employee(User):
employee_id=models.CharField(max_length=250)
eworkplace=models.ForeignKey(Workplace,on_delete=models.CASCADE)
Upvotes: 0
Views: 125
Reputation: 116
In django, you can make them both able to authenticate, or register, by setting a OneToOneField
to User
in your WorkPlace and Employee models. If you have set this user as AUTH_USER_MODEL
= <yourapp.User>
in settings, you will be able to register with the models that have set this field.
Upvotes: 1