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

Avoid rewriting admin.register() to decorator after unregister #239

Closed
adamchainz opened this issue Sep 24, 2022 · 0 comments · Fixed by #249
Closed

Avoid rewriting admin.register() to decorator after unregister #239

adamchainz opened this issue Sep 24, 2022 · 0 comments · Fixed by #249

Comments

@adamchainz
Copy link
Owner

Description

Currently the new admin.register fixer from #182 moves register() calls after unregister() calls:

+@admin.register(User)
 class CustomUserAdmin(...):
     ...

 admin.site.unregister(User)
-admin.site.register(User, CustomUserAdmin)

This is unsafe!

Update the fixer to detect unregister calls and avoid rewriting.

@andreasschmitz

andreasschmitz pushed a commit to andreasschmitz/django-upgrade that referenced this issue Sep 24, 2022
Updates the "register admin" fixer to ignore register calls if
preceded by an unregister.
andreasschmitz added a commit to andreasschmitz/django-upgrade that referenced this issue Sep 24, 2022
Updates the "register admin" fixer to ignore register calls if
preceded by an unregister.
adamchainz pushed a commit to andreasschmitz/django-upgrade that referenced this issue Sep 27, 2022
Updates the "register admin" fixer to ignore register calls if
preceded by an unregister.
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

Successfully merging a pull request may close this issue.

1 participant