Greetings. I decided to extend the basic User model for Django (1.9.7) (say, by adding the balance field). Added AUTH_PROFILE_MODULE in settings.py . Created a model in models.py:

 from django.contrib.auth.models import AbstractBaseUser, User from django.db import models from decimal import Decimal class MyUser(AbstractBaseUser): user = models.ForeignKey(User) balance = models.DecimalField(..., max_digits=7, decimal_places=0, default=Decimal('0')) 

Through the built-in forms, authorization and registration work. But if to address to user.balance nothing. Also, if you try to delete an account from the admin panel, an error appears:

(1146, "Table 'mydatabase.project_myuser' does not exist").

Well, there is no balance field in the admin either. Please help to understand.

    1 answer 1

    You do not need a foreign key on the user if you inherit from AbstractBaseUser
    And you don't have to use this abstract class. If you just want to add fields to the model, inherit from AbstractUser
    AbstractBaseUser needed if you want to completely override the user model

     from django.contrib.auth.models import AbstractUser class MyUser(AbstractUser): balance = models.DecimalField(max_digits=7, decimal_places=0, default=Decimal('0')) 

    And write in the settings.py redefined model:
    AUTH_USER_MODEL = "<название приложения>.MyUser"

    (1146, "Table 'mydatabase.project_myuser' does not exist")

    This error indicates that the table is not in the database, most likely you forgot to make the migration. Make them after you fix the model