after that i see it more than 40 times in django.admin.contrib.options.py
...
{{{
def __str__(self):
return "%s.%s" % (self.model._meta.app_label,
self.__class__.__name__) # r.n. 593
}}}
...
{{{
info = self.model._meta.app_label, self.model._meta.model_name # r.n. 620
}}}
It's easy to change with find/replace
--
Ticket URL: <https://code.djangoproject.com/ticket/33028>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* owner: nobody => Maxim Danilov
* status: new => assigned
* type: Uncategorized => Cleanup/optimization
--
Ticket URL: <https://code.djangoproject.com/ticket/33028#comment:1>
* stage: Unreviewed => Accepted
Comment:
Hi Maxim.
I'll provisionally accept this for review. Let's see what the cleanup
looks like.
This have been the same for a long time. (e.g. Many of the lines are
unchanged since a19ed8aea395e8e07164ff7d85bd7dff2f24edca.) We can't change
the API here, and it might be that it's not worth it looking at the diff,
but in principle yes, a bit more consistency of usage might make it easier
to follow.
Thanks
--
Ticket URL: <https://code.djangoproject.com/ticket/33028#comment:2>
* owner: Maxim Danilov => Marcelo Galigniana
Comment:
Hello!
I can do the find/replace to see how the diff looks like.
But I would suggest to do the opposite way: remove the use of `self.opts`
and use `._meta` instead (which in my opinion it's easier; at least to get
more consistency). What do you think?
I did a quick search in my local project and I got:
- For ".opts" -> **66** results in **11** files
- For "model._meta" -> **980** results in **134** files
- And just "._meta" -> **2215** results in **225** files
--
Ticket URL: <https://code.djangoproject.com/ticket/33028#comment:3>
* owner: Marcelo Galigniana => Maxim Danilov
Comment:
Hi Marcelo.
If i use ModelAdmin.opts, i use public Attribute from instance and i can
override it for my needs.
i think it is right.
If in ModelAdmin placed self.model._meta, at first it is wrong to use
privat property from other object, at second - it is possible, but more
difficult to override it.
That's why i see ModelAdmin.opts is a right way for Django.
--
Ticket URL: <https://code.djangoproject.com/ticket/33028#comment:4>
Comment (by Marcelo Galigniana):
Thank you for the explanation Maxim! And sorry again!
Replying to [comment:4 Maxim Danilov]:
> Hi Marcelo.
> If i use ModelAdmin.opts, i use public Attribute from instance and i can
override it for my needs.
> i think it is right.
>
> If in ModelAdmin placed self.model._meta, at first it is wrong to use
privat property from other object, at second - it is possible, but more
difficult to override it.
>
> That's why i see ModelAdmin.opts is a right way for Django.
>
>
--
Ticket URL: <https://code.djangoproject.com/ticket/33028#comment:5>
* owner: Maxim Danilov => (none)
* status: assigned => new
--
Ticket URL: <https://code.djangoproject.com/ticket/33028#comment:6>
* owner: (none) => Marcelo Galigniana
* status: new => assigned
--
Ticket URL: <https://code.djangoproject.com/ticket/33028#comment:7>
* has_patch: 0 => 1
--
Ticket URL: <https://code.djangoproject.com/ticket/33028#comment:8>
Comment (by Marcelo Galigniana):
[https://github.com/django/django/pull/15782 PR]
--
Ticket URL: <https://code.djangoproject.com/ticket/33028#comment:9>
* needs_better_patch: 0 => 1
--
Ticket URL: <https://code.djangoproject.com/ticket/33028#comment:10>
* needs_better_patch: 1 => 0
--
Ticket URL: <https://code.djangoproject.com/ticket/33028#comment:11>
* stage: Accepted => Ready for checkin
--
Ticket URL: <https://code.djangoproject.com/ticket/33028#comment:12>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"d80a2585532ef15184afed6cf4ec1358198a894d" d80a2585]:
{{{
#!CommitTicketReference repository=""
revision="d80a2585532ef15184afed6cf4ec1358198a894d"
Fixed #33028 -- Used ModelAdmin's opts attribute instead of model._meta.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/33028#comment:13>