Advertisement
Guest User

Untitled

a guest
Nov 28th, 2014
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Settings.py:
  2.  
  3. INSTALLED_APPS = (
  4.     'django.contrib.admin',
  5.     'django.contrib.auth',
  6.     'django.contrib.contenttypes',
  7.     'django.contrib.sessions',
  8.     'django.contrib.messages',
  9.     'django.contrib.staticfiles',
  10.     'fwdeveryone',
  11. )
  12.  
  13. MIDDLEWARE_CLASSES = (
  14.     'django.contrib.sessions.middleware.SessionMiddleware',
  15.     'django.middleware.common.CommonMiddleware',
  16.     'django.middleware.csrf.CsrfViewMiddleware',
  17.     'django.contrib.auth.middleware.AuthenticationMiddleware',
  18.     'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
  19.     'django.contrib.messages.middleware.MessageMiddleware',
  20.     'django.middleware.clickjacking.XFrameOptionsMiddleware',
  21. )
  22.  
  23. #Authentication backends
  24. AUTHENTICATION_BACKENDS = (
  25.     'django.contrib.auth.backends.ModelBackend',
  26. )
  27.  
  28. Views.py:
  29.  
  30. from __future__ import print_function
  31. from __future__ import unicode_literals
  32. from __future__ import division
  33. from __future__ import absolute_import
  34.  
  35. from django.shortcuts import get_object_or_404
  36. from django.http import HttpResponseRedirect, HttpResponse
  37. from django.core.urlresolvers import reverse
  38. from django.template import RequestContext
  39. from django.contrib.auth import authenticate, logout
  40. from django.contrib.auth import login as auth_login
  41. from django.contrib.auth import get_user_model
  42. from django.contrib.auth.models import User
  43.  
  44. def signup(request):
  45.     if request.method == 'POST':
  46.         username = request.POST['username']
  47.         email = request.POST['email']
  48.         password = request.POST['password']
  49.  
  50.         user = MyUser.objects.create_user(username, email, password)
  51.         user.save()
  52.  
  53.     user = authenticate(username=username, password=password) #Always returns none
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement