title: uploaded file is not storing in the database in django
body: <p>i am trying to make a form where banks upload a file every month but my code is fully running with all the success alerts but neither anything is getting stored in the database nor the file is getting stored in the media folder.</p>
  
  <blockquote>
    <p>my models.py file</p>
  </blockquote>
  
  <pre><code>from django.db import models
  from django.contrib.auth import get_user_model
  from datetime import datetime
  
  # Create your models here.
  class BusinessAccount(models.Model):
      user = models.OneToOneField(
          get_user_model(),
          on_delete=models.CASCADE,
          primary_key=True,
      )
  
      def __str__(self):
          return self.user.first_name
  
  def user_directory_path(instance, filename):
      user = instance.user.user.first_name
      current_month = (datetime.now()).strftime("%B")
      return 'CIR/{0}/{1}/{2}'.format(user, current_month, filename)
  
  class UploadFile(models.Model):
      user = models.ForeignKey(
          BusinessAccount,
          on_delete=models.CASCADE,
      )
      month = models.DateField()
      cir = models.FileField(null = False, upload_to=user_directory_path)
  
      def __str__(self):
          return self.user.user.first_name
  </code></pre>
  
  <blockquote>
    <p>my views.py file</p>
  </blockquote>
  
  <pre><code>@login_required
  def upload(request):
          if request.method == 'POST':
              form = UploadFileForm(request.POST, request.FILES, instance=user)
              if form.is_valid():
                  file = form.save(commit=False)
                  if 'cir' in request.FILES:
                      file.cir = request.FILES['cir']
                      print(file.cir)
                      file.save()
                      messages.success(request,('File is sucessfully uploaded'))
                      return HttpResponseRedirect(reverse('business:upload'))
                  else:
                      messages.error(request,('Please upload a valid file!'))
              else:
                  print(form.errors)
                  messages.error(request,(form.errors))
          else:
              form = UploadFileForm()
          return render(request,'upload.html',{'form': form})
  </code></pre>
  
  <blockquote>
    <p>my forms.py file</p>
  </blockquote>
  
  <pre><code>class UploadFileForm(forms.ModelForm):
      cir = forms.FileField(widget=forms.FileInput(attrs={'class':'form-control-file'}))
  
      class Meta:
          model = UploadFile
          fields = ('cir',)
  </code></pre>
  
  <blockquote>
    <p>and my template</p>
  </blockquote>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  {% extends "base.html" %}
  {% block body_block %}
    &lt;div class="container"&gt;
      &lt;div class="jumbotron jumbotron-fluid"&gt;
        {% for message in messages %}
  
                     &lt;div class="alert alert-success"&gt;
                         &lt;a class="close" href="{% url 'personal:profile_form' %}" data-dismiss="alert"&gt;×&lt;/a&gt;
  
                         {{ message }}
  
                     &lt;/div&gt;
        {% endfor %}
        &lt;form role="form" enctype="multipart/form-data" method="POST"&gt;
          {% csrf_token %}
          &lt;div class="form-group"&gt;
            &lt;label for="exampleFormControlFile1"&gt;&lt;h1&gt;Upload This Month's CIR&lt;/h1&gt;&lt;/label&gt;
            {{form.cir}}
          &lt;/div&gt;
          &lt;button type="submit" class="btn btn-success"&gt;Upload&lt;/button&gt;
        &lt;/form&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  {% endblock %}
  </code></pre>
  
  <p>i am a little new in django so please any body could help me please</p>