Where do you monkey patch custom model Django?

I want the monkey to fix the user model from Django.

My code is:

from django.db import models

from django.contrib.auth.models import User
User.add_to_class('secret_question', models.CharField(max_length="100"))
User.add_to_class('answer', models.CharField(max_length="100"))
User.add_to_class('DOB', models.DateField())

Where to place this code so that it python manage.py syncdbcreates the correct table?

I tried the main directory models.py, I tried the application directory models.py(these two did not give the correct table), and I tried to put it in the settings.pyproject (error, can't run).

+3
source share
2 answers

Pay attention to Saving additional user information in authentication documentation. It offers a cleaner way to add additional information to a User object.

, , Django - - " ".

+6

, . Django-primate

django.

Django django, , django.contrib.auth.

+2

All Articles