title: Django document upload form not displaying in browser
body: <p>This is actually a class assignment i am working on. I created models, views and form classes for document upload and registration in django. I have been consulting different tutorials and trying different techniques, that is why there might be different approaches in my codes. Forgive me for that <em>newbie alert.</em></p>
  
  <ol>
  <li>First problem: The registration form does not submit to the table (Users). I added users from the admin end and it logs in perfectly.</li>
  </ol>
  
  <p><strong>Model.py</strong></p>
  
  <pre><code>class Users(models.Model):
      id = models.AutoField(primary_key=True, unique=True)
      title = models.CharField(max_length='10')
      surname = models.CharField(max_length='50')
      firstname = models.CharField(max_length='50')
      username = models.CharField(max_length='50')
      password = models.CharField(max_length='50')
      email = models.EmailField(max_length='50')
      phone = models.BigIntegerField(max_length='12')
      city = models.CharField(max_length='50')
      country = models.CharField(max_length='50')
      usertype = models.CharField(max_length=13)
  </code></pre>
  
  <p><strong>Form.py</strong></p>
  
  <pre><code> class RegisterForm(forms.Form):
          #define fields for form
          title = forms.CharField(max_length='10')
          surname = forms.CharField(max_length='10')
          firstname = forms.CharField(max_length='10')
          username = forms.CharField(max_length='50')
          password = forms.PasswordInput()
          email = forms.EmailField(required=True)
          phone = forms.CharField(max_length='15')
          city = forms.CharField(max_length='50')
          country = forms.CharField(max_length='20')
          userlevel = (
              (u'Client', 'Client'),
              (u'Proof Reader', 'Proof Reader'),
              (u'Admin', 'Admin'),
          )
          usertype = forms.ModelChoiceField( widget=forms.Select, queryset=userlevel )
  
          class Meta:
              model = Users
              fields = ('username', 'email', 'password', 'password2')
  
      def save(self, commit=True):
              Users = super(RegisterForm, self).save(commit=False)
              Users.title = self.cleaned_data['title']
              Users.surname = self.cleaned_data['surname']
              Users.firstname = self.cleaned_data['firstname']
              Users.username = self.cleaned_data['username']
              Users.password = self.cleaned_data['password']
              Users.email = self.cleaned_data['email']
              Users.phone = self.cleaned_data['phone']
              Users.city = self.cleaned_data['city']
              Users.country = self.cleaned_data['country']
              Users.usertype = self.cleaned_data['usertype']
              if commit:
                  Users.save()
                  return Users
  
      def clean_username(self):
                      username = self.cleaned_data['username']
                      try:
                              User.objects.get(username=username)
                      except User.DoesNotExist:
                              return username
                      raise forms.ValidationError("That username is already taken, please select another.")
  </code></pre>
  
  <p><strong>View.py</strong></p>
  
  <pre><code>def register(request):
      #model = Users
      #check  the request object if there is a method post for a form action
      if request.method == 'POST':
          #handle the form if method is found to be post
          #create a form object
          form = RegisterForm(request.POST)
          context = {'form': RegisterForm}
          #check if form is valid
          if form.is_valid():
              #save form
              Users.title = form.cleaned_data['title']
              Users.surname = form.cleaned_data['surname']
              Users.firstname = form.cleaned_data['firstname']
              Users.username = form.cleaned_data['username']
              Users.password = form.cleaned_data['password']
              Users.email = form.cleaned_data['email']
              Users.phone = form.cleaned_data['phone']
              Users.city = form.cleaned_data['city']
              Users.country = form.cleaned_data['country']
              Users.usertype = form.cleaned_data['usertype']
              #redirect to success page
              return HttpResponseRedirect('register_success')
          else:
              form = RegisterForm()
              #create arguments to check against CSRF attacks
      args = {}
      args.update(csrf(request))
      args['form'] = RegisterForm()
      return render_to_response('register.html', args)
  
  def auth_view(request):
      username = request.POST.get('username', '')
      password = request.POST.get('password', '')
      user = auth.authenticate(username=username, password=password)
  
      if user is not None:
          auth.login(request, user)
          return HttpResponseRedirect('welcome')
      else:
          return HttpResponseRedirect('invalid')
          #return render_to_response('auth_view.html')
  </code></pre>
  
  <p><strong>Template file - register.html</strong></p>
  
  <pre><code>{% extends "main.html" %}
  {% block title %}Register{% endblock %}
  {% block content %}
      &lt;h2&gt;Register&lt;/h2&gt;
  
      &lt;form action="" method="post"&gt; {% csrf_token %}
    &lt;table&gt; {{ form }} &lt;/table&gt;
      &lt;input type="submit" value="Register"&gt;
      &lt;/form&gt;
  
  {% endblock %}
  </code></pre>
  
  <ol>
  <li>Form for document upload also is not displaying. I have no idea why this is happening. </li>
  </ol>
  
  <p><strong>Models.py</strong></p>
  
  <pre><code>class document(models.Model):
      id = models.AutoField(primary_key=True, unique=True)
      file = models.FileField(upload_to=get_upload_file_name)
      statusid = models.ForeignKey('status')
      userID = models.ForeignKey('Users')
      #feedback = models.TextField(blank=True)
      time = models.DateTimeField()
      completion_time = models.DateTimeField(blank=True)
      choice = ((u'Audio', 'Audio'), (u'Text', 'Text'))
      filetype = models.CharField(max_length='50')
  </code></pre>
  
  <p><strong>views.py</strong></p>
  
  <pre><code>def uploaddocs(request):
      if request.method == 'POST':
          form = DocumentForm(request.POST, request.FILES)
          context = {'form': DocumentForm}
          if form.is_valid():
                 form.upload()
                 return HttpResponseRedirect('upload_success')
  
      args = {}
      args.update(csrf(request))
      args['forms'] = DocumentForm()
      return render_to_response('uploaddocs.html', args)
  </code></pre>
  
  <p><strong>forms.py</strong></p>
  
  <pre><code>class DocumentForm(forms.Form):
      #define fields for form
      model = document
      file = forms.FileField()
      statusid = forms.CharField(max_length='10')
      userID = forms.CharField(max_length='10')
      #feedback = models.TextField(blank=True)
      time = forms.DateTimeField()
      completion_time = forms.DateTimeField()
      choice = ((u'Audio', 'Audio'), (u'Text', 'Text'))
      filetype = forms.ChoiceField(choices=choice)
  
  def upload(self, commit=True):
     document = DocumentForm.save(commit=False)
     document.statusid = self.cleaned_data['statusid']
     document.time = self.cleaned_data['time']
     document.completion_time = self.cleaned_data['completion_time']
     document.filetype = self.cleaned_data['filetype']
     if commit:
         document.upload()
         return document
  </code></pre>
  
  <p>I know this seems like the whole assignment but believe me, this is just the beginning of my many errors to come. Thanks for your replies.</p>