title: 'NoneType' object has no attribute 'user'
body: <p>models.py</p>
  
  <pre><code>class Report(models.Model):
      user = models.ForeignKey(User, null=False)
      photo_files_attached = models.BooleanField('Photos', default=False)
  </code></pre>
  
  <p>views.py</p>
  
  <pre><code>def media(request):
      user = request.user  
      try:
  
          report = Report.objects.get(user=user.id)
      except:
          report = None
  
      report_dir = str(report.user.id) + '/' + str(report.id)
      output_dir = settings.MEDIA_ROOT + '/' + report_dir
      imagelist = []
      if os.path.exists(output_dir):
          os.chdir(output_dir)
          for files in os.listdir("."):
              for extension in JPEG_ALLOWED:
                  if files.endswith(extension):
                      image_with_path = report_dir + '/' + files
                      imagelist.append(image_with_path)
      return render(request, 'incident/media.html',
                    {
                     'newreport_menu': True,
                     'report':report,
  
                   })   
  </code></pre>
  
  <p>I am trying to upload the image file and save it to database,getting the below error "<code>'NoneType' object has no attribute 'user'</code>" </p>