K
K
KarenG2015-05-10 23:19:24
Django
KarenG, 2015-05-10 23:19:24

How to add a field to an existing model in django?

Can you please tell me how to update the existing default django User model? Need to add a new field

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
Evgeny Maltsev, 2015-05-10
@hellpirat

Customizing authentication in Django¶

Z
zigen, 2015-05-13
@zigen

class UserProfile(models.Model):
    # This line is required. Links UserProfile to a User model instance.
    user = models.OneToOneField(User)
    # The additional attributes we wish to include.
    website = models.URLField(blank=True)

    # Override the __unicode__() method to return out something meaningful!
    def __str__(self):
        return self.user.username

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question