Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Created Superusers at the command line have no matching Staff object #45

Closed
profcturner opened this issue Mar 20, 2021 · 1 comment
Closed
Assignees
Milestone

Comments

@profcturner
Copy link
Owner

Two people have tried to install WAM and run into this issue. The code now will cause exceptions if a User has no matching Staff object, and yet the createsuperuser does not create the Staff.

Hmm, it’s actually probably a flaw in that your user object has no matching staff user, and something I will definitely need to resolve. We must file an issue on that.

In the mean time, try something like the following will work around this.

python3 manage.py shell

Python 3.6.1 (v3.6.1:69c0db5050, Mar 21 2017, 01:21:04)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)

from loads.models import Staff
from django.contrib.auth.models import User
users = User.objects.all()
users[0]
<User: TEST1000>
root_user = users[0]
staff = Staff.objects.create(user=root_user, title="Mr", staff_number="whatever")

@profcturner profcturner self-assigned this Oct 8, 2021
@profcturner
Copy link
Owner Author

The decorator @staff_only has been altered to create a Staff object for superusers with no matching Staff object, this should allow created superusers to log in without any further drama.

@profcturner profcturner added this to the 2.1.1 milestone Nov 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant