0

I want to add a column to django auth_user table. But I do not want to create a new table.

As the document peovided for extending User model, there are four ways.

  • proxy model

  • Add a oneToOne field

  • Creating a Custom User Model Extending AbstractUser

  • Creating a Custom User Model Extending AbstractBaseUser

It works some time. But How could I add a field to the auth user model it provied?

sksun27
  • 1
  • 2
  • You can possibly see it in here https://simpleisbetterthancomplex.com/tutorial/2016/07/22/how-to-extend-django-user-model.html where you took those points :). Use `AbstractUser`. – Ahtisham Jan 22 '19 at 08:00
  • As I said, these method did not solve my problem.Which I want is to add column on the origin table auth_table, if create a custom model, it will create a new table as well, that is not what i want – sksun27 Jan 22 '19 at 08:10
  • 2
    no `AbstractUser` does not create a new table. It adds yours fields to the `User` table. But you **must** have to do this setup when you are creating your project otherwise it throws error which are kind hard to solve. – Ahtisham Jan 22 '19 at 08:32
  • thank you.This works for me – sksun27 Jan 22 '19 at 08:40
  • Did you implemented it ? – Ahtisham Jan 22 '19 at 08:53
  • See my answer here: https://stackoverflow.com/questions/42478191/django-how-to-add-an-extra-field-in-user-model-and-have-it-displayed-in-the-adm/54305092#54305092 – Ahtisham Jan 22 '19 at 09:30

0 Answers0