title: django upload a file from other python script
body: <p>I want to save file from the client to the django project server's database from a script. I've tried to do this using a model and a view in the django project, and post request in the other python script, but it keeps return 403 error and not save the file and the data to the database.</p>
  
  <p>models.py:</p>
  
  <pre><code>class ScreenRecord(models.Model):
          record = models.FileField(default='output.avi', upload_to='records')
          writeTime = models.DateTimeField(auto_now_add=True)
          user = models.ForeignKey(User, on_delete=models.CASCADE, default=1)
  </code></pre>
  
  <p>views.py:</p>
  
  <pre><code>def getscreenrecords(request):
      user = User.objects.filter(username=request.POST.get('user')).first()
      k = ScreenRecord(record=request.FILES.get('record'), user=user)
      k.save()
      return HttpResponse('success ' + request.GET.__getitem__('user'))
  </code></pre>
  
  <p>url.py:</p>
  
  <pre><code>from . import views
  
  urlpatterns = [
      path('screenrecords/', views.getscreenrecords, name='getscreenrecords'),
  ]
  </code></pre>
  
  <p>python script to send the file:</p>
  
  <pre><code>url = 'http://127.0.0.1:8000/send/screenrecords/'
  files = {'record': open('output.avi','rb')}
  values = {'user': 'newUser'}
  r = requests.post(url, files=files, data=values)
  print(r)
  </code></pre>
  
  <p>what's wrong in my code or is there a way to do this better?</p>