Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class UserForm(forms.ModelForm):
- password = forms.CharField(widget=forms.PasswordInput())
- class Meta:
- model = User
- fields = ('username', 'email', 'password')
- class UserProfileForm(forms.ModelForm):
- class Meta:
- model = UserProfile
- fields = ('website', 'picture')
- #----- views.py----------------------------
- def user_login(request):
- # Like before, obtain the context for the user's request.
- context = RequestContext(request)
- if request.method == 'POST':
- # Gather the username and password provided by the user.
- # This information is obtained from the login form.
- username = request.POST['username']
- password = request.POST['password']
- user = authenticate(username=username, password=password)
- if user:
- # Is the account active? It could have been disabled.
- if user.is_active:
- login(request, user)
- return HttpResponseRedirect('/rango/')
- else:
- return HttpResponse("Your Rango account is disabled.")
- else:
- # Bad login details were provided. So we can't log the user in.
- print "Invalid login details: {0}, {1}".format(username, password)
- return HttpResponse("Invalid login details supplied.")
- else:
- return render_to_response('rango/login.html', {}, context)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement