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

Moving to adminplus locks out superuser from editing #77

Open
isoboroff opened this issue Feb 28, 2024 · 2 comments
Open

Moving to adminplus locks out superuser from editing #77

isoboroff opened this issue Feb 28, 2024 · 2 comments

Comments

@isoboroff
Copy link

When I add SimpleAdminConfig in settings.py, and set admin.site to a new AdminSitePlus in urls.py, I get the message "You don’t have permission to view or edit anything." when logged in as a superuser.

If I revert those two edits, switching back to the standard admin, I can see and edit as usual.

Happy to help debug but not sure where to start.

@isoboroff
Copy link
Author

Aha. This happens if you don't explicitly call admin.autodiscover(). I thought it wasn't necessary since I had stuff in admin.py. I only see the tables for my app and not the auth tables, but I suspect this is related.

@isoboroff
Copy link
Author

isoboroff commented Feb 28, 2024

And the problem is if you use the @admin.register decorator rather than admin.site.register(). According to https://docs.djangoproject.com/en/4.2/ref/contrib/admin/#the-register-decorator, the call to the decorator needs to also point to the new Admin site.

Now, if you use any other package, and it uses the @admin.register decorator, it won't know about adminplus. For example, contrib.auth. And so, nothing in admin.

This sounds like a bug so I won't close this out. I can't decide if it's a Django bug or an adminplus bug.

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