Answer the question
In order to leave comments, you need to log in
Django formset extension for ManyToMany through tables?
Greetings Toaster Members!
I managed to make a form for OneToMany tables using inlineformset_factory () with the ability to edit, but I can’t figure out which class needs to be extended in this case, to edit ManyToMany through tables, if for example there is a banal structure of posts and tags tables:
from django.db import models
class Post(models.Model):
title = models.CharField(max_length=128)
tags = models.ManyToManyField('Tag', through='PostTag')
class Tag(models.Model):
tag_name = models.CharField(max_length=128)
posts = models.ManyToManyField(Post, through='PostTag')
class PostTag(models.Model):
post = models.ForeignKey(Post, on_delete=models.CASCADE)
tag = models.ForeignKey(Tag, on_delete=models.CASCADE)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question