0

I would like to create new fields in the model of the Django's User system. I am following the official documentation, but I keep getting the same error:

Same problem executing: runserver, makemigrations, migrate

My changes so far to the code have been the following:

models.py:

from django.db import models
from django.contrib.auth.models import AbstractUser
# Create your models here.

class User(AbstractUser):
    bio = models.TextField(max_length=500,blank=True)
    location = models.CharField(max_length=30, blank=True)
    birth_date = models.DateField(null=True, blank=True)

admin.py

from django.contrib import admin
from django.contrib.auth.admin import UserAdmin
from .models import User

admin.site.register(User, UserAdmin)
  • 1
    Are you changing an existing project from using the standard `django.contrib.auth.User` to using your own custom user? i.e. did you migrate previously before you changed `AUTH_USER_MODEL` (and have you changed `AUTH_USER_MODEL`)? Read [this](https://docs.djangoproject.com/en/stable/topics/auth/customizing/#substituting-a-custom-user-model) please. – dirkgroten Apr 03 '20 at 16:46
  • 1
    have you added AUTH_USER_MODEL = 'APPNAME.User' in your settings? – bmons Apr 03 '20 at 16:50
  • @bmons that solved it. Afterwards I got still an error and had to delete the database and the migrations history. Right now, everything is working again, but the fields that I wanted to have are not displayed at the admin panel. Am I missing something ? Thank you very much –  Apr 03 '20 at 17:05
  • @ÁlvaroValero You have to add `fieldsets` to your admin.py file. – joshlsullivan Sep 09 '20 at 14:10

0 Answers0