Reputation: 167
In the classical example of Articles/Publications, when I create a Publication record in Admin page, I would like to be able to add existing Articles to that Publication. How can I do that?
I tried following:
class PublicationAdmin(admin.ModelAdmin):
articles = Article.objects.all()
admin.site.register(Publication, PublicationAdmin)
though I do not see any articles to select at all.
I can do the other way around, when I add a new article, I can select a publication by adding
class ArticleAdmin(admin.ModelAdmin):
fieldsets =[('Publications', {'fields': ['publications']})]
Upvotes: 1
Views: 398
Reputation: 20672
You need to define an InlineModelAdmin
on the through
model, in your case the through
model is Publication.article_set.through
. See the docs.
Upvotes: 1