Guest User

Untitled

a guest
Feb 11th, 2019
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. def login_my_user(request):
  2. name = request.POST.get('username', '')
  3. pwd = request.POST.get('password', '')
  4. user = authenticate(username=name, password=pwd)
  5. if user is not None:
  6. if user.is_active:
  7. login(request, user)
  8. #redirect to authenticated page
  9.  
  10. # Middleware Settings
  11.  
  12. MIDDLEWARE_CLASSES = (
  13. 'django.middleware.common.CommonMiddleware',
  14. 'django.middleware.csrf.CsrfViewMiddleware',
  15. 'django.contrib.sessions.middleware.SessionMiddleware',
  16. 'django.contrib.auth.middleware.AuthenticationMiddleware',
  17. )
  18.  
  19.  
  20. # apps
  21.  
  22. INSTALLED_APPS = (
  23. 'django.contrib.contenttypes',
  24. 'django.contrib.staticfiles',
  25. 'django.contrib.sessions',
  26. 'django.contrib.auth',
  27. 'test'
  28. )
  29.  
  30.  
  31. #Template
  32. TEMPLATE_LOADERS = (
  33. 'django.template.loaders.filesystem.Loader',
  34. 'django.template.loaders.app_directories.Loader',
  35. )
  36. TEMPLATE_DIRS = (
  37. PROJECT_DIR + "/templates",
  38. )
  39. TEMPLATE_CONTEXT_PROCESSORS = (
  40. 'django.contrib.auth.context_processors.auth',
  41. 'django.core.context_processors.debug',
  42. 'django.core.context_processors.i18n',
  43. 'django.core.context_processors.media',
  44. 'django.core.context_processors.static',
  45. 'django.contrib.auth.context_processors.auth',
  46. )
  47.  
  48. def user_dashboard(request):
  49. user = request.user
  50. print user
  51.  
  52. AUTHENTICATION_BACKENDS = ('django.contrib.auth.backends.ModelBackend',)
Add Comment
Please, Sign In to add comment