# why django inlineformset\_factory not saving the froms data?

**URL:** <https://forum.djangoproject.com/t/why-django-inlineformset-factory-not-saving-the-froms-data/8000>\
**Category:** Using Django\
**Created:** [May 21, 2021, 5:41pm UTC](https://forum.djangoproject.com/t/why-django-inlineformset-factory-not-saving-the-froms-data/8000 "2021-05-21T17:41:15Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![MDFARHYN](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/mdfarhyn/32/4519_2.png) [@MDFARHYN](https://forum.djangoproject.com/u/MDFARHYN)\
**Post date:** [May 21, 2021, 5:41pm UTC](https://forum.djangoproject.com/t/why-django-inlineformset-factory-not-saving-the-froms-data/8000/1 "2021-05-21T17:41:15Z")

</div>

Why inlineformset\_factory froms data not saving ? field is rendering in my html template but froms data not saving. here is my code:

**models.py**

```auto
class HeaderImage(models.Model):
      header_image = models.ImageField()
      post = models.ForeignKey(Post, on_delete=models.CASCADE)

```

**froms.py**

```auto
BlogImageFormSet = inlineformset_factory(Post, # parent form
                                                  HeaderImage, # inline-form

                                                fields=['header_image'] ,can_delete=False, extra=1)

```

**#views.py**

```auto
class BlogUpdateView(PermissionRequiredMixin,UpdateView):
      raise_exception = True
      permission_required = "blog.change_post"
      model = Post
      template_name = "blog_update_post.html"
      form_class = BlogPost

      def get_success_url(self):
        self.success_url = reverse_lazy('my-account')
        return self.success_url
      
      def get_context_data(self, **kwargs):
        context = super(BlogUpdateView, self).get_context_data(**kwargs)
        if self.request.POST:
            context['form_image'] = BlogImageFormSet(self.request.POST, instance=self.object)
             
        else:
            context['form_image'] = BlogImageFormSet(instance=self.object)
             
        return context
      

      def form_valid(self, form):
            context = self.get_context_data()
            image_form = context['form_image']

            if image_form.is_valid():
                  self.object = form.save()
                  image_form.instance = self.object
                  image_form.save()
                  return HttpResponseRedirect(self.get_success_url())
            else:
                  return self.render_to_response(self.get_context_data(form=form))

```

I am not understanding why data is not saving for inlineformset\_factory field.

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [May 21, 2021, 7:55pm UTC](https://forum.djangoproject.com/t/why-django-inlineformset-factory-not-saving-the-froms-data/8000/2 "2021-05-21T19:55:33Z")

</div>

What errors or responses are you getting from the submit? If you’re not getting any tracebacks, what error messages are being returned to the form? (Are you displaying error messages in your form? If not, it would be worth printing any existing error messages before you exit the form\_valid function.)

---

<div class="post-metadata">

**Author:** ![MDFARHYN](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/mdfarhyn/32/4519_2.png) [@MDFARHYN](https://forum.djangoproject.com/u/MDFARHYN)\
**Post date:** [May 21, 2021, 9:12pm UTC](https://forum.djangoproject.com/t/why-django-inlineformset-factory-not-saving-the-froms-data/8000/3 "2021-05-21T21:12:31Z")

</div>

Thanks [KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell) for your replay. I am not getting any error. Others models fields data saving except fields of inlineformset\_factory. see the picture

 ![Capture](https://us1.discourse-cdn.com/flex026/uploads/djangoproject/original/2X/8/879d4a00fcc5e17c81c102b821c267a4c1c5b777.png)

I am not understanding why data of inlineformset\_factory not saving.

---

<div class="post-metadata">

**Author:** ![colina83](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/colina83/32/6569_2.png) [@colina83](https://forum.djangoproject.com/u/colina83)\
**Post date:** [December 6, 2021, 1:51pm UTC](https://forum.djangoproject.com/t/why-django-inlineformset-factory-not-saving-the-froms-data/8000/4 "2021-12-06T13:51:25Z")

</div>

HI,

I was reviewing your topic regarding inline formset, and I’m having an issue saving my data as well

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [December 6, 2021, 2:10pm UTC](https://forum.djangoproject.com/t/why-django-inlineformset-factory-not-saving-the-froms-data/8000/5 "2021-12-06T14:10:33Z")

</div>

If you are interested in getting assistance with your issue, I would suggest you open a new topic, posting all the relevant information.  
That would include a complete description of what’s happening, along with all the code involved - models, views, and templates.  
When posting code, post the actual code in the message - no screenshots. Enclose the code between lines of three backtick - ` characters. This means you’ll have a line of ```, then the code, then another line of ```. (You can do that multiple times in one post - you could have some text, a line of ```, some code, another line of ```, more text, etc)
