Opened 9 years ago
Closed 9 years ago
#25039 closed Cleanup/optimization (invalid)
Automatic setup verbose_name for related fields
Reported by: | Grigoriy Kramarenko | Owned by: | nobody |
---|---|---|---|
Component: | Uncategorized | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
In a large multilingual projects often lack the simplest things. To edit verbose_name for related objects occurred in one place.
Before:
class Foo(models.Model): ... class Meta: verbose_name = _('foo') class Bar(models.Model): foo = models.ForeignKey(Foo, verbose_name=_('foo'))
After:
class Foo(models.Model): ... class Meta: verbose_name = _('foo') class Bar(models.Model): foo = models.ForeignKey(Foo)
This patch only works when you specify a class and not a lazy reference to the object.
It also reduces the memory consumption.
Attachments (1)
Change History (4)
by , 9 years ago
Attachment: | 25039.diff added |
---|
follow-up: 2 comment:1 by , 9 years ago
comment:2 by , 9 years ago
Replying to timgraham:
The patch uses deprecated APIs so the test suit can't run, but even when updated as below, there are still problems running the tests.
if self.verbose_name is None and self.remote_field and not isinstance(self.remote_field.model, six.string_types): self.verbose_name = self.remote_field.model._meta.verbose_name
Sorry, that was meant for 1.8, I'll try to rewrite under master
comment:3 by , 9 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
Bad idea. It's works, but in order to do have to change a bunch of tests.
The patch uses deprecated APIs so the test suit can't run, but even when updated as below, there are still problems running the tests.