K
K
KIN19912015-04-17 14:05:30
Django
KIN1991, 2015-04-17 14:05:30

How to change the title of the TabularInline field?

Hello everyone, there is a problem, I did TabularInline on the ManyToMany field in the admin panel. Everything works fine, but there is one problem with one header, I can’t change this header in any way (see picture). How can I do that?
3cfbebe869904e0baa0dc58952b4b911.png
Models

class Users(AbstractBaseUser):
    ....
    pages = models.ManyToManyField(Pages,related_name="permissions",verbose_name='Страницы')

class Pages(models.Model):
    ...
    def __unicode__(self):
            return self.title
    class Meta:
          	verbose_name = 'Страницы'
            verbose_name_plural = 'Страницы'

Admin class for TabularInline
class PermissionsAdmin(admin.TabularInline):
    model = Users.pages.through
    model.__unicode__ = lambda x: u'Страницы'
    model._meta.verbose_name = 'доступ'
    model._meta.verbose_name_plural ='доступ'
    extra = 1

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
KIN1991, 2015-04-20
@KIN1991

In general, I figured it out myself, this is done in the following way

class PermissionsAdmin(admin.TabularInline):
    model = Users.pages.through
    model.__unicode__ = lambda x: u'Выбирите страницу'
    model._meta.verbose_name = 'объект'
    model._meta.verbose_name_plural ='права доступа'
    model._meta.local_fields[2].verbose_name = 'Страница'

A
Anatoly Scherbakov, 2015-04-18
@Altaisoft

Try like this.

class PermissionsAdmin(admin.TabularInline):
    model = Users.pages.through
    verbose_name_plural = 'Права доступа'

In fact, it would be more correct not to write Russian lines in the code, but whatever is more convenient for you.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question