0

I use Django 1.8 and apache 2.2. I have mod_wsgi installed and everything works except user authentication. I can attempt to login with a wrong password (which it will check and send back with false) Only when username and password is correct I receive a 500 error. I have tried the following settings.py

import os
from django.conf.global_settings import TEMPLATE_CONTEXT_PROCESSORS as TCP
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'Map' 
)

TEMPLATE_CONTEXT_PROCESSORS = TCP + (
'django.core.context_processors.request',
'django.core.context_processors.auth',
'django.core.context_processors.debug',
"django.core.context_processors.i18n",
"django.core.context_processors.media",
"django.core.context_processors.static",
"django.core.context_processors.tz",
"django.contrib.messages.context_processors.messages"

 )

 MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.security.SecurityMiddleware',
)

ROOT_URLCONF = 'MyApp.urls'

TEMPLATES = [
{
    'BACKEND': 'django.template.backends.django.DjangoTemplates',
    'DIRS': [],
    'APP_DIRS': True,
    'OPTIONS': {
        'context_processors': [
            'django.template.context_processors.debug',
            'django.template.context_processors.request',
            'django.contrib.auth.context_processors.auth',
            'django.contrib.messages.context_processors.messages',
        ],
    },
 },
]

WSGI_APPLICATION = 'MyApp.wsgi.application'

in the apache sites-enabled:

<VirtualHost *:80>
 ServerName  myapp.org

 WSGIScriptAlias / /home/MyApp/wsgi.py
 Alias /static/ /home/MyApp/static/

 <Directory /home/MyApp/static> 

       Order allow,deny
       Allow from all
 </Directory>


 <Directory /home/MyApp/>
     <Files wsgi.py>
         Order allow,deny
         Allow from all
 </Files>
 </Directory>

 ErrorLog /var/log/apache2/error.log
 LogLevel warn
 CustomLog /var/log/apache2/MyApp.log combined

</VirtualHost>

Error ONLY happens when login should be succesfull. Am I missing any settings?

Henkes
  • 288
  • 4
  • 16
  • Try temporarily setting ``DEBUG`` to ``True`` in the Django settings file so you can see in the browser what the actual error was that caused the 500 response. Don't forget to disable debug when done as you don't want that in a public facing machine. – Graham Dumpleton Jul 01 '15 at 09:39
  • Solved, apache didn't have access to the database. in the end I had to: `chown www-data:www-data /srv/mysite chown www-data:www-data /srv/mysite/DATABASE.sqlite` to make sure apache got access. Thank you for your help anyway! – Henkes Jul 01 '15 at 11:05

1 Answers1

0

In the end it seems apache didn't have write permission on the SQLite database. I fixed this by doing: chown www-data:www-data /srv/mysite chown www-data:www-data /srv/mysite/DATABASE.sqlite as seen in the answer of niekas.

Community
  • 1
  • 1
Henkes
  • 288
  • 4
  • 16