title: Django uploading files for user
body: <p>I am able to upload the files in django. I have also managed to register different users.
  But when the users log in , they all see the set of files that were uploaded by anyone.
  instead I want the user views only those set of files which he/she has uploaded.</p>
  
  <p>Here is my models.py </p>
  
  <pre><code>class Document(models.Model):
      docfile = models.FileField(upload_to='documents/%Y/%m/%d')
  </code></pre>
  
  <p>views.py</p>
  
  <pre><code>def list(request):
  
      if request.method == 'POST':
          form = DocumentForm(request.POST, request.FILES)
          if form.is_valid():
              newdoc = Document(docfile = request.FILES['docfile'])
              newdoc.save()
  
              # Redirect to the document list after POST
              return HttpResponse("File Uploaded.. Kindly Refresh!!")
      else:
          form = DocumentForm() # A empty, unbound form
  
      # Load documents for the list page
      documents = Document.objects.all()
  
      # Render list page with the documents and the form
      return render_to_response(
          'login/list.html',
          {'documents': documents, 'form': form},
          context_instance=RequestContext(request)
      )
  </code></pre>
  
  <p>LIST.html</p>
  
  <pre><code> &lt;table cellpadding=20&gt;
      {% for document in documents %}
          &lt;tr&gt;
              &lt;td&gt;&lt;a href="{{ document.docfile.url }}"&gt;{{ document.docfile.name }}&lt;/a&gt; &lt;/td&gt;
              &lt;td&gt;&lt;/td&gt;
              &lt;td&gt;&lt;/td&gt;
              &lt;td&gt;&lt;a href="delete/{{ document.docfile.name }}"&gt; Delete&lt;/a&gt;&lt;/td&gt;
  
          &lt;/tr&gt;
      {% endfor %}
      &lt;/table&gt;
  
    {% else %}
      &lt;p&gt;No documents.&lt;/p&gt;
    {% endif %}
  </code></pre>