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

Fixed #33028 -- Used ModelAdmin's opts attribute instead of model._meta. #15782

Merged
merged 1 commit into from Jun 22, 2022

Conversation

mgaligniana
Copy link
Member

@mgaligniana mgaligniana commented Jun 20, 2022

Ticket ModelAdmin.init has self.opts, but it still nowerewhere else in django.admin.contrib.options not used

As the ticket mentions I cleaned up just the django/contrib/admin/options.py file and the two classes that inherit from ModelAdmin (ActionAdmin and UserAdmin)

I found other files where self.model._meta is used without define a self.opts. If you think it's worth it I can do it in a different commit or PR or new ticket!

Thanks!

@mgaligniana mgaligniana marked this pull request as ready for review June 20, 2022 18:16
@felixxm
Copy link
Member

felixxm commented Jun 21, 2022

I found other files where self.model._meta is used without define a self.opts. If you think it's worth it I can do it in a different commit or PR or new ticket!

I don't think it's worth changing, _meta is heavily used in Django internals and there is nothing wrong with that. In the ModelAdmin we have self.opts already defined so using it's more natural than refetching self.model._meta.

@felixxm felixxm self-assigned this Jun 21, 2022
Copy link
Member

@felixxm felixxm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mgaligniana Thanks 👍 I found few more cases:

django/contrib/admin/options.py Show resolved Hide resolved
@mgaligniana
Copy link
Member Author

mgaligniana commented Jun 22, 2022

I couldn't figure out how replace the last case: get_formset(): when does self._meta.model._meta.verbose_name as it's inherit from ModelForm

@felixxm felixxm changed the title Fixed #33028 -- ModelAdmin.init has self.opts, but it still nowerewhere else in django.admin.contrib.options not used Fixed #33028 -- Used ModelAdmin's opts attribute instead of model._meta. Jun 22, 2022
@felixxm
Copy link
Member

felixxm commented Jun 22, 2022

@mgaligniana Thanks for updates 👍

I couldn't figure out how replace the last case: get_formset(): when does self._meta.model._meta.verbose_name as it's inherit from ModelForm

Yes, my mistake.

@felixxm felixxm merged commit d80a258 into django:main Jun 22, 2022
@felixxm felixxm temporarily deployed to schedules June 23, 2022 03:19 Inactive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants