开发者

Django Model Formset With ManyToMany Inline

I would like to store groups of pages under different tags. So I create these models:

class Page(models.Model):
    title = models.CharField(max_length=50)

class Tag(models.Model):
    title = models.CharField(max_length=50)
    pages = models.ManyToManyField(Page)

I would then like to create a model form(set?) that will allow me to edit the tag, and every page attached to that tag, 开发者_开发问答as one big form. I believe this is what happens when you use Model Inline Formset, but that uses foreign keys. This is a reusable app, right now I'm just rendering the form in a template, but I would prefer to use django forms so it's easier to reuse.

I can't seem to figure out how this is done, any suggestions would be greatly appreciated.


I also had the same problem, but I was using a generic relation please study my post link is given below. U can use inline formset in the same way. If you have any more problem u can get back to me.

< Creating form using Generic_inlineformset_factory from the Model Form >

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜