Pavan Kumar
Pavan Kumar

Reputation: 1891

Django admin site, reverse the model association

Right now I have the following models.

class Publisher(models.Model):
    name = models.CharField()


class Article(models.Model):
    name = models.CharField()
    publisher = models.ManyToManyField(Publisher, related_name='articles', blank=True)

When I go to Django admin site -> add/edit Article page, I get the select list of the Article to link.

But when I go to Add/Edit Publisher page I don't see a select list to associate Article

  1. How to show Article list in Publisher add/edit page.
  2. How to hide Publisher list in Article add/edit page.

Upvotes: 0

Views: 104

Answers (1)

Oleksandr Chernihov
Oleksandr Chernihov

Reputation: 61

  1. You should implement ArticleInline and add it to PublisherAdmin.inlines. Check more info about inlines
  2. Just add publisher to ArticleAdmin.exclude

Upvotes: 1

Related Questions