S
S
Sama Samsonov2016-12-28 06:15:27
Django
Sama Samsonov, 2016-12-28 06:15:27

How to remove a column from a many-to-many relation in the django admin?

Hello! Can you please tell me how to display a column from a many-to-many relationship in the django admin panel?

class books(models.Model):
    name = models.CharField(max_length=50, verbose_name=u'Название книги')
    year = models.IntegerField(max_length=10, verbose_name=u'Год выпуска')
    author = models.ManyToManyField(author)

class author(models.Model):
    full_name = models.CharField(max_length=50, verbose_name=u'Автор')

Content of admin.py:
from django.contrib import admin
from support.models import books, author

@admin.register(Author)
class BooksAdmin(admin.ModelAdmin):
    list_display = ['name', 'year', 'ЧТО_ТУТ_НАПИСАТЬ?']

What you need to write so that the third column appears, in which the authors of the book will be displayed (through a line break).

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question