Guest User

Untitled

a guest
Jun 14th, 2018
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.00 KB | None | 0 0
  1. from django.template import RequestContext
  2. from django.shortcuts import render_to_response
  3. from django.http import HttpResponseRedirect, HttpResponse
  4. from django.core.urlresolvers import reverse
  5. from django import forms
  6.  
  7. def login(request):
  8.     if request.method == 'POST': #if the form has been submitted...
  9.         form = ContactForm(request.POST) # form bount to the POST data
  10.         if form.is_valid(): # all validation rules pass
  11.             # process teh data in form.cleaned_data
  12.             # ...
  13.             return HttpResponseRedirect ('/main/') # redirect after post
  14.     else:
  15.         form = ContactForm() # unbound form
  16.  
  17.     return render_to_response ("login.html", {
  18.         'form' : form, }, context_instance = RequestContext (request))
  19.  
  20. def main_page(request):
  21.     return HttpResponse("WOOHOO")
  22.  
  23. class ContactForm(forms.Form):
  24.     Username = forms.CharField(max_length = 100)
  25.     Password = forms.CharField(label = (u'Password'), widget = forms.PasswordInput(render_value = False))
Add Comment
Please, Sign In to add comment