After I switched my Abstract User my login/admin page on dev couldn't sign using Debug = True and python manage.py runserver.
It works on prod though without any issues.
When logging in on development I get
Please enter a correct username and password. Note that both fields may be case-sensitive.
I also deleted my sqlite db and used makemigrations on it.
All I wanted to do was add a single field to the user so they can upload a file.
models.py
from django.db import models
from django.contrib.auth.models import AbstractUser
class Profile(AbstractUser):
""" bio = models.TextField(max_length=500, blank=True)
phone_number = models.CharField(max_length=12, blank=True)
birth_date = models.DateField(null=True, blank=True) """
avatar = models.ImageField(default='default.png', upload_to='users/', null=True, blank=True)
admin.py
from django.contrib import admin
from django.contrib.auth.admin import UserAdmin
from .models import Profile
class CustomUserAdmin(UserAdmin):
pass
admin.site.register(Profile, CustomUserAdmin)
settings.py
# Extends default user with additional fields
AUTH_USER_MODEL = 'pages.Profile'
When I used migrations
(portfolio) PS C:\Users\arund\Desktop\Code\Django\portfolio-project> python manage.py showmigrations
admin
[X] 0001_initial
[X] 0002_logentry_remove_auto_add
[X] 0003_logentry_add_action_flag_choices
auth
[X] 0001_initial
[X] 0002_alter_permission_name_max_length
[X] 0003_alter_user_email_max_length
[X] 0004_alter_user_username_opts
[X] 0005_alter_user_last_login_null
[X] 0006_require_contenttypes_0002
[X] 0007_alter_validators_add_error_messages
[X] 0008_alter_user_username_max_length
[X] 0009_alter_user_last_name_max_length
[X] 0010_alter_group_name_max_length
[X] 0011_update_proxy_permissions
[X] 0012_alter_user_first_name_max_length
contenttypes
[X] 0001_initial
[X] 0002_remove_content_type_name
pages
[X] 0001_initial
sessions
[X] 0001_initial
Traceback from trying to login with Debug = True
When logging in on development I get
(portfolio) PS C:\Users\arund\Desktop\Code\Django\portfolio-project> python manage.py runserver
Watching for file changes with StatReloader
Performing system checks...
System check identified no issues (0 silenced).
December 18, 2021 - 13:11:34
Django version 3.2.9, using settings 'portfolio.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
[18/Dec/2021 13:11:46] "GET / HTTP/1.1" 200 753
Not Found: /favicon.ico
[18/Dec/2021 13:11:47] "GET /favicon.ico HTTP/1.1" 404 2716
[18/Dec/2021 13:11:49] "GET /accounts/login/ HTTP/1.1" 200 1215
[18/Dec/2021 13:11:50] "POST /accounts/login/ HTTP/1.1" 200 1369
[18/Dec/2021 13:12:03] "POST /accounts/login/ HTTP/1.1" 200 1368
[18/Dec/2021 13:12:22] "POST /accounts/login/ HTTP/1.1" 200 1368
[18/Dec/2021 13:12:30] "POST /accounts/login/ HTTP/1.1" 200 1368
[18/Dec/2021 13:12:36] "POST /accounts/login/ HTTP/1.1" 200 1368
[18/Dec/2021 13:12:43] "POST /accounts/login/ HTTP/1.1" 200 1368
[18/Dec/2021 13:13:15] "POST /accounts/login/ HTTP/1.1" 200 1368
CodePudding user response:
Did you run python manage.py createsuperuser
after deleting database?