[Fixed]-Separate classes for different user types in Django

1👍

This is a common anti pattern. Don’t do this. You will have to spend thrice the effort to make your project work. Instead what you need is a UserProfile model (which you will have to create anyway for most projects)

class UserProfile(models.Model):
    ADMIN = 'A'
    MOBILE = 'M'
    EXTERNAL = 'E'

    USER_CHOICES = ( (ADMIN,'Admin), ....)

    user = models.OnetoOneField(User)
    user_type = models.CharField(max_length=2,choices = USER_CHOICES )

This gives you the same information but there’s only one model and iet’s simpler to implement and maintain

👤e4c5

Leave a comment