Question

I have been dealing for a while with Django's authentication system and I just cannot understand why I have to go through this process Django doc! :

from django.contrib.auth.models import User

class Employee(models.Model):
    user = models.OneToOneField(User)
    department = models.CharField(max_length=100)

... rather than simply extending the "User" class like this:

class Employee(User):
     ....

... and re-using all the code contained within. I have taken a look at articles like: b-list.org! , and I understand that the problem may be related with the automatic Django database management.

Is there a way in which I can automatically extend the User model without having to create an additional table in the database, so that Django modifies the current database table for me?

Was it helpful?

Solution

I tend to obey the fellas of the django

https://docs.djangoproject.com/en/1.5/topics/auth/customizing/#extending-the-existing-user-model

Because only abstract models don't create tables in django and built-in user model is not

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top