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)

25039.diff (679 bytes ) - added by Grigoriy Kramarenko 9 years ago.

Download all attachments as: .zip

Change History (4)

by Grigoriy Kramarenko, 9 years ago

Attachment: 25039.diff added

comment:1 by Tim Graham, 9 years ago

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

in reply to:  1 comment:2 by Grigoriy Kramarenko, 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 Grigoriy Kramarenko, 9 years ago

Resolution: invalid
Status: newclosed

Bad idea. It's works, but in order to do have to change a bunch of tests.

Note: See TracTickets for help on using tickets.
Back to Top