Hey Matthew
I learn about your Youtube Video "Getting Started with Django". If i make the User Model with AbstractUser i never can login in my admin.
I registrated the leads app in my Settings.
I testet the config with and without AUTH_USER_MODEL = 'leads.User'
but it never works. What i make false?
# leads/model.py
from django.db import models
from django.contrib.auth.models import AbstractUser
class User(AbstractUser):
pass
class Lead (models.Model):
first_name = models.CharField(max_length=50)
last_name = models.CharField(max_length=50)
age = models.IntegerField(default=0)
agent = models.ForeignKey("Agent", on_delete=models.CASCADE)
def __str__(self):
return f"{self.first_name} {self.last_name}"
class Agent(models.Model):
user = models.OneToOneField(User, on_delete=models.CASCADE)
first_name = models.CharField(max_length=20)
last_name = models.CharField(max_length=20)
def __str__(self):
return self.user.email
# leads/admin.py
from django.contrib import admin
from .models import User, Lead, Agent
class LeadAdmin(admin.ModelAdmin):
model = Lead
list_display = ('first_name', 'last_name', 'age', 'agent')
admin.site.register(User)
admin.site.register(Lead, LeadAdmin)
admin.site.register(Agent)
(venv) CRM_Tutorial> python3.exe .\manage.py
runserver
Watching for file changes with StatReloader
Performing system checks...
Exception in thread django-main-thread:
Traceback (most recent call last):
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.496.0_x64__qbz5n2kfra8p0\lib\threading.py", line 954, in _bootstrap_inner
self.run()
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.496.0_x64__qbz5n2kfra8p0\lib\threading.py", line 892, in run
self._target(*self._args, **self._kwargs)
File "C:\Users\Christoph\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\django\utils\autoreload.py", line 53, in wrapper
fn(*args, **kwargs)
File "C:\Users\Christoph\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\django\core\management\commands\runserver.py", line 118, in inner_run
self.check(display_num_errors=True)
File "C:\Users\Christoph\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\django\core\management\base.py", line 442, in check
raise SystemCheckError(msg)
django.core.management.base.SystemCheckError: SystemCheckError: System check identified some issues:
ERRORS:
auth.User.groups: (fields.E304) Reverse accessor for 'User.groups' clashes with reverse accessor for 'User.groups'.
HINT: Add or change a related_name argument to the definition for 'User.groups' or 'User.groups'.
auth.User.user_permissions: (fields.E304) Reverse accessor for 'User.user_permissions' clashes with reverse accessor for 'User.user_permissions'.
HINT: Add or change a related_name argument to the definition for 'User.user_permissions' or 'User.user_permissions'.
leads.User.groups: (fields.E304) Reverse accessor for 'User.groups' clashes with reverse accessor for 'User.groups'.
HINT: Add or change a related_name argument to the definition for 'User.groups' or 'User.groups'.
leads.User.user_permissions: (fields.E304) Reverse accessor for 'User.user_permissions' clashes with reverse accessor for 'User.user_permissions'.
HINT: Add or change a related_name argument to the definition for 'User.user_permissions' or 'User.user_permissions'.
System check identified 4 issues (0 silenced).
Hey Matthew I learn about your Youtube Video "Getting Started with Django". If i make the User Model with AbstractUser i never can login in my admin.
but it never works. What i make false?
Best regards Christoph