1

Hello I am very new to Django, and I am making an app that stores a lot of information about the user. But django's auth app stores only a bit of information about the user. Is there any way I can create my own model "User" and make Django's auth app use this model. Thanks.

Adil Malik
  • 8,410
  • 10
  • 53
  • 83

3 Answers3

1

You can solves your problem with UserProfile model. And you can store the user extra information in this with relation of onetone or ForeignKey with unique property field.

Django user profile

Community
  • 1
  • 1
dhana
  • 6,217
  • 4
  • 38
  • 61
1

U can multi-table inheritance the user model

from django.contrib.auth import User

class MyUser(User):
//add ur required fields

Reference for in heritance.

sundar nataraj
  • 8,200
  • 2
  • 30
  • 44
1

This has been supported since Django 1.5, and is fully covered in the documentation.

Basically, you need to subclass auth.models.AbstractUser, and set the AUTH_USER_MODEL setting to point to your new model.

Daniel Roseman
  • 567,968
  • 59
  • 825
  • 842
  • if I make a model "User", in my app, that subclassess the auth.models.AbstractUser then will it be used the same way as the auth's User. I mean can I do something like `request.user.city` – Adil Malik Apr 21 '14 at 08:59
  • Yes that's the whole point, as long as you set AUTH_USER_MODEL. – Daniel Roseman Apr 21 '14 at 09:27