User profile issue when creating user with Django administration

1,314 views
Skip to first unread message

Daniel McQuillen

unread,
Feb 22, 2016, 10:42:52 PM2/22/16
to Open edX operations
Seems like when you create a user with the Django admin panel the resulting user object isn't getting a profile object. 

I logged into the Django administration panel as a super user. I created a staff user, making sure to check "active" and "staff status" and gave the user a couple roles just for kicks. Staff status has help text that reads: "Designates whether the user can log into this admin site" so my assumption is this user should now be able to log into the Django admin panel.

However, when I try to log into the Django administration panel as this new user, I get a 500 error because Django can't find a 'profile' object for that user.

  ...

  File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/dispatch/dispatcher.py", line 189, in send

    response = receiver(signal=self, sender=sender, **named)

  File "/edx/app/edxapp/edx-platform/common/djangoapps/student/models.py", line 1783, in enforce_single_login

    user.profile.set_login_session(key)

  File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/db/models/fields/related.py", line 483, in __get__

    self.related.get_accessor_name()

RelatedObjectDoesNotExist: User has no profile.


Interestingly, if I I create a staff user manually with the following steps, the user does get a profile:

sudo -u www-data /edx/bin/python.edxapp ./manage.py lms --settings aws create_user -s -p edx -e some_sta...@example.com
sudo -u www-data /edx/bin/python.edxapp ./manage.py lms --settings aws changepassword some_staff_member
sudo -u www-data /edx/bin/python.edxapp ./manage.py lms --settings aws shell

from django.contrib.auth.models import User
staff = User.objects.get(username="some_staff_member")
staff.is_staff = True staff.save()

I can log into the Django administration panel with this user without a problem.

Are there other operations you have to do on a user in the admin panel to give that new user a profile?


Daniel McQuillen

unread,
Feb 22, 2016, 10:56:21 PM2/22/16
to Open edX operations
... and strange to find these lines in edx-platform/lms/envs/common.py, (line 1845)

    # For testing
    'django.contrib.admin',  # only used in DEBUG mode

Does that mean the Django Administration panel on the lms isn't to be used for a live, running Open EdX system?

Anna Winklerová

unread,
Mar 29, 2016, 9:32:31 AM3/29/16
to Open edX operations
Hi.

I'm struggling too. All the user accounts created from Django admin can sign into Studio but not into LMS. It gives me RelatedObjectDoesNotExist: User has no profile LMS log error and says An error has occurred. Try refreshing the page, or check your Internet connection on the sign in page. Since it is the unsupported Cypress installation I give up and create users from shell via

sudo -u www-data /edx/bin/python.edxapp ./manage.py lms --settings aws create_user -e user_...@example.com -u username -p password

I could swear the Django admin create user worked in the beginning of February. But I wouldn't put my life on it. Since users can create their accounts themselves I will not dig any deeper.

-- Anna

Dne úterý 23. února 2016 4:42:52 UTC+1 Daniel McQuillen napsal(a):

Mahyar Damavand

unread,
May 24, 2016, 11:40:41 AM5/24/16
to Open edX operations
Hello
You are right Anna...
I freshly installed open Edx on a vps and I can't login to lms and DjangoAmin through myNewUser which I created via django shell command:
/edx/app/edxapp/edx-platform/manage.py lms --settings=aws createsuperuser --username myNewUser
but I can login to studio

I logged in through studio and changed to admin and created another new user there
The new one can't login too

Does any one have a solution for this?
Reply all
Reply to author
Forward
0 new messages