1

I had a login page that I would change it to another login page and I follow these instructions.

I added this code and when I tried to login to my user admin that I added before it sends me to wrong url http://localhost:8050/admin/login/?next=/admin/ and it throws :

RelatedObjectDoesNotExist at /admin/login/

User has no profile
Selcuk
  • 57,004
  • 12
  • 102
  • 110

2 Answers2

0

The profile instance is generated on post_save signal, that is, you must save your User at least once after you added that Profile class.

The easiest workaround in your case would be to create a new admin user using python manage.py createsuperuser.

Selcuk
  • 57,004
  • 12
  • 102
  • 110
0

The error seems like, You have a User in DB, but it doesn't have any profile relation now.

Solution:1
Set profile instance for currently existing User's in db through django shell.
1. log into django shell by python manage.py shell
2. run these commands,

from django.contrib.auth.models import User
from myapp.models import Profile

for user in User.objects.all():
    Profile.objects.create(user=user)

3. then login to the django admin


Solution:2
Drop your database, (if you are using sqlite, the delete the corresponding file) and migrate and then create a new super user by python manage.py createsuperuser command

JPG
  • 82,442
  • 19
  • 127
  • 206