Just finished the Django tutorial. Starting my own project. Using the ManyToMany Relationship example here. I added in the following controls in my admin.py:
class ArticleInline(admin.TabularInline):
model = Article
extra = 3
class PublicationAdmin(admin.ModelAdmin):
inlines = [ArticleInline]
admin.site.register(Publication, PublicationAdmin)
But when I try to add a publication in the admin page, it says:
<class 'polls.models.Article'> has no ForeignKey to <class 'polls.models.Publication'>
Do I have to initialize an article before I can create a publication? Does creating a publication make Django look for an article?
Thanks for the help. Just starting out. It’s pretty overwhelming, but very exciting.
If you’re using a many to many relationship, you need to access the actual through model.
I’m assuming you have something like:
Assuming that construction, you access the
throughmodel using the attribute spelled similarly:Hope that helps!