Editing related objects in ModelFormSet

后端 未结 1 1812
慢半拍i
慢半拍i 2020-12-21 09:20

I have these Models:

class Gallery(models.Model):
   HeadImage = models.ImageField(upload_to=\"gallery\")

class Image(models.Model):
   Image = models.Image         


        
1条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-21 09:39

    It looks like you are manually rendering the form in your template, and missing out the id field. Make sure you include {{ form.id }} for each form in the formset.

    {{ formset.management_form }} {% for form in formset %} {{ form.id }}
    • {{ form.title }}
    {% endfor %}

    See the docs on using model formsets in the template for more information.

    0 讨论(0)
提交回复
热议问题