Hey guys. I created a custom user model like so:
from django.db import models
from django.contrib.auth.models import (
AbstractBaseUser,
BaseUserManager,
PermissionsMixin
)
class UserManager(BaseUserManager):
"""Class for creating a user manager"""
def create_user(self, email, password=None, **extrafields):
"""Create, save and return a new user."""
if not email:
raise ValueError('An email address is required for user registration.')
user = self.model(
email=self.normalize_email(email),
**extrafields
)
user.set_password(password)
user.save(using=self._db)
return user
def create_superuser(self, email, password):
user = self.create_user(email, password)
user.is_staff = True
user.is_superuser = True
user.save(using=self._db)
return user
class User(AbstractBaseUser, PermissionsMixin):
"""Model for custom definition of system user fields"""
email = models.EmailField(max_length=255, unique=True)
name = models.CharField(max_length=255)
is_active = models.BooleanField(default=True)
is_staff = models.BooleanField(default=False)
objects = UserManager()
USERNAME_FIELD = 'email'
When I try to access the changelist in Django admin, I get the following error:
Template error:
In template /py/lib/python3.14/site-packages/django/contrib/admin/templates/admin/change_list.html, error at line 46
'super' object has no attribute 'dicts' and no __dict__ for setting new attributes
36 : {% endblock %}
37 : {% endif %}
38 :
39 : {% block coltype %}{% endblock %}
40 :
41 : {% block content %}
42 : <div id="content-main">
43 : {% block object-tools %}
44 : <ul class="object-tools">
45 : {% block object-tools-items %}
46 : {% change_list_object_tools %}
47 : {% endblock %}
48 : </ul>
49 : {% endblock %}
50 : {% if cl.formset and cl.formset.errors %}
51 : <p class="errornote">
52 : {% blocktranslate count counter=cl.formset.total_error_count %}Please correct the error below.{% plural %}Please correct the errors below.{% endblocktranslate %}
53 : </p>
54 : {{ cl.formset.non_form_errors }}
55 : {% endif %}
56 : <div class="module{% if cl.has_filters %} filtered{% endif %}" id="changelist">
Traceback (most recent call last):
File "/py/lib/python3.14/site-packages/django/core/handlers/exception.py", line 55, in inner
response = get_response(request)
^^^^^^^^^^^^^^^^^^^^^
File "/py/lib/python3.14/site-packages/django/core/handlers/base.py", line 220, in _get_response
response = response.render()
^^^^^^^^^^^^^^^^^
File "/py/lib/python3.14/site-packages/django/template/response.py", line 114, in render
self.content = self.rendered_content
^^^^^^^^^^^^^^^^^^^^^
File "/py/lib/python3.14/site-packages/django/template/response.py", line 92, in rendered_content
return template.render(context, self._request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/py/lib/python3.14/site-packages/django/template/backends/django.py", line 107, in render
return self.template.render(context)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/py/lib/python3.14/site-packages/django/template/base.py", line 171, in render
return self._render(context)
^^^^^^^^^^^^^^^^^^^^^
File "/py/lib/python3.14/site-packages/django/template/base.py", line 163, in _render
return self.nodelist.render(context)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/py/lib/python3.14/site-packages/django/template/base.py", line 1008, in render
return SafeString("".join([node.render_annotated(context) for node in self]))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/py/lib/python3.14/site-packages/django/template/base.py", line 969, in render_annotated
return self.render(context)
^^^^^^^^^^^^^^^^^^^^
File "/py/lib/python3.14/site-packages/django/template/loader_tags.py", line 159, in render
return compiled_parent._render(context)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/py/lib/python3.14/site-packages/django/template/base.py", line 163, in _render
return self.nodelist.render(context)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/py/lib/python3.14/site-packages/django/template/base.py", line 1008, in render
return SafeString("".join([node.render_annotated(context) for node in self]))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/py/lib/python3.14/site-packages/django/template/base.py", line 969, in render_annotated
return self.render(context)
^^^^^^^^^^^^^^^^^^^^
File "/py/lib/python3.14/site-packages/django/template/loader_tags.py", line 159, in render
return compiled_parent._render(context)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/py/lib/python3.14/site-packages/django/template/base.py", line 163, in _render
return self.nodelist.render(context)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/py/lib/python3.14/site-packages/django/template/base.py", line 1008, in render
return SafeString("".join([node.render_annotated(context) for node in self]))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/py/lib/python3.14/site-packages/django/template/base.py", line 969, in render_annotated
return self.render(context)
^^^^^^^^^^^^^^^^^^^^
File "/py/lib/python3.14/site-packages/django/template/loader_tags.py", line 65, in render
result = block.nodelist.render(context)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/py/lib/python3.14/site-packages/django/template/base.py", line 1008, in render
return SafeString("".join([node.render_annotated(context) for node in self]))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/py/lib/python3.14/site-packages/django/template/base.py", line 969, in render_annotated
return self.render(context)
^^^^^^^^^^^^^^^^^^^^
File "/py/lib/python3.14/site-packages/django/template/loader_tags.py", line 65, in render
result = block.nodelist.render(context)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/py/lib/python3.14/site-packages/django/template/base.py", line 1008, in render
return SafeString("".join([node.render_annotated(context) for node in self]))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/py/lib/python3.14/site-packages/django/template/base.py", line 969, in render_annotated
return self.render(context)
^^^^^^^^^^^^^^^^^^^^
File "/py/lib/python3.14/site-packages/django/template/loader_tags.py", line 65, in render
result = block.nodelist.render(context)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/py/lib/python3.14/site-packages/django/template/base.py", line 1008, in render
return SafeString("".join([node.render_annotated(context) for node in self]))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/py/lib/python3.14/site-packages/django/template/base.py", line 969, in render_annotated
return self.render(context)
^^^^^^^^^^^^^^^^^^^^
File "/py/lib/python3.14/site-packages/django/contrib/admin/templatetags/base.py", line 45, in render
return super().render(context)
^^^^^^^^^^^^^^^^^^^^^^^
File "/py/lib/python3.14/site-packages/django/template/library.py", line 273, in render
new_context = context.new(_dict)
^^^^^^^^^^^^^^^^^^
File "/py/lib/python3.14/site-packages/django/template/context.py", line 275, in new
new_context = super().new(values)
^^^^^^^^^^^^^^^^^^^
File "/py/lib/python3.14/site-packages/django/template/context.py", line 112, in new
new_context = copy(self)
^^^^^^^^^^
File "/usr/local/lib/python3.14/copy.py", line 82, in copy
return copier(x)
^^^^^^^^^
File "/py/lib/python3.14/site-packages/django/template/context.py", line 160, in __copy__
duplicate = super().__copy__()
^^^^^^^^^^^^^^^^^^
File "/py/lib/python3.14/site-packages/django/template/context.py", line 41, in __copy__
duplicate.dicts = self.dicts[:]
^^^^^^^^^^^^^^^
Exception Type: AttributeError at /admin/core/user/
Exception Value: 'super' object has no attribute 'dicts' and no __dict__ for setting new attributes
What changes can I make to the custom user model to prevent the error. Thanks in advance.