2👍
✅
I am not sure that it can meet your needs but i’ve done something similar by using TabularInline. Somethink like this should work (i didn’t test the following code).
class Subject(models.Model):
...
class News(models.Model):
subject = models.ManyToManyField(Subject, through="NewsSubject")
class NewsSubject(models.Model):
news = models.ForeignKey(News)
subject = models.ForeignKey(Subject)
class NewsOfSubjectInline(admin.TabularInline):
model = NewsSubject
raw_id_fields = ('news',)
class SubjectAdmin(admin.ModelAdmin):
inlines = [NewsOfSubjectInline,]
class SubjectOfNewsInline(admin.TabularInline):
model = NewsSubject
raw_id_fields = ('subject',)
class NewsAdmin(admin.ModelAdmin):
inlines = [SubjectOfNewsInline,]
👤luc
Source:stackexchange.com