I have an application in django 1.6 and a problem with /admin/ address on live.
When I go to this address on the live gets a 404 error.
Nginx log says that I have no file or directory:
/path_to_project/live/admin/index.html "not found (2: No such file or directory)
Locally, everything works and the project does not have the index.html file in the admin directory.
Please for help.
My urls:
from django.conf.urls import patterns, include, url
from django.conf.urls.static import static
from django.conf import settings
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
url(r'^admin/', include(admin.site.urls)),
url(r'^', include('presentationtool.urls')),
) + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
My settings:
from django.conf.global_settings import TEMPLATE_CONTEXT_PROCESSORS as TCP
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
TEMPLATE_DEBUG = True
ALLOWED_HOSTS = ['*']
TEMPLATE_DIRS = (
os.path.join(BASE_DIR, 'templates'),
)
# Application definition
DEFAULT_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
)
THIRD_PARTY_APPS = (
'south',
'easy_thumbnails',
)
ADMIN_APPS = (
'suit',
'adminsortable',
)
LOCAL_APPS = (
'myapp',
)
INSTALLED_APPS = ADMIN_APPS + DEFAULT_APPS + THIRD_PARTY_APPS + LOCAL_APPS
MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
)
ROOT_URLCONF = 'www.urls'
WSGI_APPLICATION = 'www.wsgi.application'
TEMPLATE_CONTEXT_PROCESSORS = TCP + (
'django.core.context_processors.request',
'django.core.context_processors.static',
)
# Database
# https://docs.djangoproject.com/en/1.6/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
# Internationalization
# https://docs.djangoproject.com/en/1.6/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.6/howto/static-files/
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, '..', 'static')
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, '..', 'media')
SOUTH_MIGRATION_MODULES = {
'easy_thumbnails': 'easy_thumbnails.south_migrations',
}
EDIT
My nginx settings:
upstream myapp_upstream {
server my_url:port;
}
server {
include inc/80.inc;
server_name
my_url_here.com;
root /path_to_project_on_server/live/;
access_log /var/log/nginx/app/myapp.live.access.log;
error_log /var/log/nginx/app/myapp.live.error.log;
access_log /var/log/nginx/app/myapp.live.upstream.log upstream;
location / {
include uwsgi_params;
uwsgi_pass myapp_upstream ;
}
location /admin {
client_max_body_size 400m;
}
location /static/ {
alias /path_to_project_on_server/live/static/;
}
location /media {
alias /path_to_project_on_server/live/media;
}
# return 302 https://my_url_here.com$request_uri;
}