Editing related objects in ModelFormSet

后端 未结 1 1809
慢半拍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.

    <form method="post" action="">
        {{ formset.management_form }}
        {% for form in formset %}
            {{ form.id }}
            <ul>
                <li>{{ form.title }}</li>
            </ul>
        {% endfor %}
    </form>
    

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

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