I am getting a similar error to this post, but it only happens when I go to the website I set up in IIS 2012R2.
I am following this tutorial to start a web app, and I used this video to set up Django with IIS. I successfully set up the Django using IIS, but I a missing the CSS on the admin page.
Note that the admin page displays the CSS items if I run the page using runserver command.
python manage.py runserver
But if I run it through http://127.0.0.1:8003/admin/ in IE (setup through IIS), I get the picture shown below. I tried this in Chrome, and it gave me same results.
Do I need configure my wfastcgi.py file to show CSS? In the video tutorial, the author talks about a static folder in IIS for JPEGS, Javascript...do I need to configure this?
I am using Django 1.8.4 and Python 3.4.
This is my current configuration:
settings.py
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.8/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '&y%=6k2y4z5_ut3z#&1l2lh3v12#zyxws)o&5^fj^ik^79pys('
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = (
'django.contrib.admin', #admin site
'django.contrib.auth', #authentication system
'django.contrib.contenttypes', #framework for content types
'django.contrib.sessions', #ssession framework
'django.contrib.messages', #messaging framework
'django.contrib.staticfiles', #framework for managing static files
'polls',
)
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 = 'FirstSite.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 = 'FirstSite.wsgi.application'
# Database
# https://docs.djangoproject.com/en/1.8/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.8/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.8/howto/static-files/
STATIC_URL = '/static/'
urls.py
from django.conf.urls import include, url
from django.contrib import admin
urlpatterns = [
url(r'^admin/', include(admin.site.urls)),]
wsgi.py
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "FirstSite.settings")
application = get_wsgi_application()
manage.py
import os
import sys
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "FirstSite.settings")
from django.core.management import execute_from_command_line
execute_from_command_line(sys.argv)
You should set your STATICFILES_DIRS settings in settings.py, to map to your static folder, where CSS, JS and images are stored.
STATIC_URL = 'http://www.example.com/static/'
STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'static'),
)
Also if you run 'manage.py collectstatic' you should define
STATIC_ROOT = "/path/to/static/destination/folder/"
This is the best way to serve static files.
Reference for STATIC settings: Django Documentation
I was able to find an answer with the help of a colleague.
The answer is highlighted here: Link
If you follow the above solution, please keep in mind the following (which is what the above person mentioned):
The Static folder where you keep all the CSS, jpegs, etc files is not the same as the static folder they are referring to in the solution
Make sure you run the command collectstatic to compile all the static files from the STATIC_URL folder to the STATIC_ROOT folder
When you run the collectstatic it will compile the Admin static files as well
Related
when I deploy *my heroku website everything loads up except my The Website Images you could see everything but it shows the images as errors I am not sure how to fix this I been stuck with this problem for almost 2 days if you know how to fix it please explain it to me so in the future I could go back and see this and fix my problem I literally have all the requirements for my website to be launched with heroku but I am not see the images at all
my settings.py
"""
Django settings for mysite project.
Generated by 'django-admin startproject' using Django 3.1.1.
For more information on this file, see
https://docs.djangoproject.com/en/3.1/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/3.1/ref/settings/
"""
import os
from pathlib import Path
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = ''
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = False # remember to change to false
ALLOWED_HOSTS = ['anim3-domain.herokuapp.com']
# 'https://anime-domain.herokuapp.com/'
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'main.apps.MainConfig',
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'whitenoise.middleware.WhiteNoiseMiddleware',
'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 = 'mysite.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 = 'mysite.wsgi.application'
# Database
# https://docs.djangoproject.com/en/3.1/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
}
}
# Password validation
# https://docs.djangoproject.com/en/3.1/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
# Internationalization
# https://docs.djangoproject.com/en/3.1/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/3.1/howto/static-files/
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
STATIC_URL = '/static/'
STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'static'),
)
my urls
"""mysite URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/3.1/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: path('', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path, include
urlpatterns = [
path('admin/', admin.site.urls),
path('', include("main.url")),
]
my wsgi.py
"""
WSGI config for mysite project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/3.1/howto/deployment/wsgi/
"""
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mysite.settings')
application = get_wsgi_application()
here is part of the error log
rWarning: No directory at: /app/staticfiles/
2020-10-10T16:21:57.649046+00:00 app[web.1]: warnings.warn(u"No directory at: {}".format(root))
2020-10-10T16:21:57.649987+00:00 app[web.1]: /app/.heroku/python/lib/python3.6/site-packages/whitenoise/base.py:115: UserWarning: No directory at: /app/staticfiles/
2020-10-10T16:21:57.649989+00:00 app[web.1]: warnings.warn(u"No directory at: {}".format(root))
heres the full error log its in pastebin because its to long stack will view it as error
https://pastebin.com/fEr8LQk1
Im having issues loading the static files for django admin using the latest django. Now i have tried multiple methods and really would appreciate help. For info im using pythonanywhere for deployment.
This is the settings.py file
"""
Django settings for MyDjangoApp project.
Generated by 'django-admin startproject' using Django 2.2.15.
For more information on this file, see
https://docs.djangoproject.com/en/2.2/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/2.2/ref/settings/
"""
import os
import server_keys as sk
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = sk.django_key
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = False
ALLOWED_HOSTS = ['192.168.1.22','localhost','username.pythonanywhere.com ','username.pythonanywhere.com']
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'regs',
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'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 = 'MyDjangoApp.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': ['regs/templates/regs'],
'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 = 'MyDjangoApp.wsgi.application'
# Database
# https://docs.djangoproject.com/en/2.2/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
# Password validation
# https://docs.djangoproject.com/en/2.2/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
# Internationalization
# https://docs.djangoproject.com/en/2.2/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'Asia/Kuwait'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/2.2/howto/static-files/
STATIC_URL = '/static/'
STATIC_ROOT = "/home/username/main/static"
STATICFILES_DIRS = [
os.path.join(BASE_DIR,"static"),
]
Based off of most tutorial and guides you would just set the path and run py manage.py collectstatic
and then it would work, but wasn't the case for me. I also got the normal static files to load but not the django admin.
My directory looks something like this: /home/username/main/Projectroot
and in the python anywhere i put the url as "static" and root as /home/username/main/static.
If im missing anymore info please let me know, i would love to deploy my project and get over this simple but annoying part, thank you!
disclaimer: I am no pro
Since you are using a virtual env, the admin files are located where you installed django, you can confirm it by running python manage.py findstatic admin/js/core.js.
check out django static files doc to see more.
A hack I used(dev server) was to copy this files into my base /static/admin folder.
I am learning Django and have built a sample Django app. It works fine on my computer, but I am having trouble deploying it to Heroku.
My root directory has the following structure:
My setttings.py file has the following settings for static files:
STATIC_URL = '/static/'
STATICFILES_DIRS = [
os.path.join(BASE_DIR, "static")
]
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
STATICFILES_STORAGE = 'whitenoise.django.GzipManifestStaticFilesStorage'
The full settings.py file is following:
"""
Django settings for firstdjango project.
Generated by 'django-admin startproject' using Django 1.8.
For more information on this file, see
https://docs.djangoproject.com/en/1.8/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.8/ref/settings/
"""
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.8/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'j8s(6fw61+cx_o=g!9a(vs!wbj0&f!7u_lw$(eap5d4li#!b4('
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'inventory',
)
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 = 'firstdjango.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': ['firstdjango/templates'],
'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 = 'firstdjango.wsgi.application'
# Database
# https://docs.djangoproject.com/en/1.8/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.8/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.8/howto/static-files/
import dj_database_url
db_from_env = dj_database_url.config(conn_max_age = 500)
DATABASES['default'].update(db_from_env)
# STATIC_URL = '/static/'
# STATICFILES_DIRS = [
# os.path.join(BASE_DIR, "static")
# ]
# STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
STATIC_URL = '/static/'
# Extra places for collectstatic to find static files.
STATICFILES_DIRS = [
os.path.join(BASE_DIR, 'static'),
]
STATICFILES_STORAGE = 'whitenoise.django.GzipManifestStaticFilesStorage'
When I try to deploy to Heroku, I get the following error message:
ImproperlyConfigured:You're using the staticfiles app without having set the STATIC_ROOT setting to a filesystem path
Here are the recommended settings for static root for a django -> heroku project
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.11/howto/static-files/
STATIC_ROOT = os.path.join(PROJECT_ROOT, 'staticfiles')
STATIC_URL = '/static/'
# Extra places for collectstatic to find static files.
STATICFILES_DIRS = [
os.path.join(PROJECT_ROOT, 'static'),
]
I would recommend just using this https://github.com/heroku/heroku-django-template as a starting point and import your apps into that project. Due to the fact (as of now) that Heroku recommends using the following packages
Gunicorn
WhiteNoise
dj-database-url
The git project will provide you with "Production-ready configuration for Static Files, Database Settings, Gunicorn, etc." In other words, it will give you the correct configuration to deploy Django to Heroku.
I was able to get my static files (CSS) to load in my local development environment, however when I push the changes to my development server I am unable to load the CSS. My local environment is Mac OS 10.9.2 and my development server is running Ubuntu 12.04.4 x64.
settings.py
import os
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'static/'),
)
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.6/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '#7h&rny3^hz&q6w-8$6k&+msh554$pz*tx#$lj(+dgctvuj2j%'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
TEMPLATE_DEBUG = True
ALLOWED_HOSTS = []
AUTHENTICATION_BACKENDS = (
'django.contrib.auth.backends.ModelBackend',
'allauth.account.auth_backends.AuthenticationBackend',
)
TEMPLATE_CONTEXT_PROCESSORS = (
'django.core.context_processors.request',
'allauth.account.context_processors.account',
'allauth.socialaccount.context_processors.socialaccount',
'django.contrib.auth.context_processors.auth',
)
# Application definition
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'pcatapp',
'south',
'django.contrib.sites',
'allauth',
'allauth.account',
'allauth.socialaccount',
'tastypie',
)
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',
#'django.core.context_processors.csrf',
)
ROOT_URLCONF = 'pcat.urls'
WSGI_APPLICATION = 'pcat.wsgi.application'
# Database
# https://docs.djangoproject.com/en/1.6/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'db',
'USER': 'root',
'PASSWORD': 'password',
'HOST': 'localhost', # Or an IP Address that your DB is hosted on
'PORT': '3306',
}
}
# 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
SITE_ID = 1
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.6/howto/static-files/
STATIC_URL = '/static/'
An excerpt from the page source:
<link rel="stylesheet" href="/static/myapp/style.css">
My static folder is located at myapp/static/myapp/style.css. All help is appreciated, thanks.
I had the same problem and dj-static provided a simple solution
$ pip install dj-static
In your wsgi.py file:
from django.core.wsgi import get_wsgi_application
from dj_static import Cling
application = Cling(get_wsgi_application())
Good Luck
When using djangos development server, I have found that this problem, and its solution normally lies in the URLS file (when DEBUG=True), something like this will allow you to use django to serve your static files:
from django.conf import settings
from django.conf.urls.static import static
urlpatterns = patterns(
'',
... url includes etc.
) + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
This will mean that any urls serving from {{ STATIC_URL }} will be handled by django, here are the django docs on this https://docs.djangoproject.com/en/dev/howto/static-files/
EDIT (Added solution for running under a webserver not django development server):
If you are running your project behind a webserver, and not using djangos runserver, then its probably best you dont use djangos static file finder, and instead use its static file collector and the webserver to serve static files, to do this, try this in your settings.py:
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
then run ./manage.py collectstatic and ensure your webserver redirects requests from /static/ to the full path of your static files directory, e.g in NGINX you might do..
location /static/ {
alias /var/www/myproject/static/;
}
And apache:
Alias /static/ /var/www/myproject/static/
Hope this helps...
I'm new to both Python and Django and am struggling with what I'm sure is a very simple thing. I'm using PyCharm as my ide and am attempting to follow quickstart guide [here][1]. I setup a virtual env as per the tutorial.
The project is "DjangoProjectApp" and the app is "Lunch"
With the files shown below and a browser pointed to http://localhost:8000/admin/ I get the error:
ImportError at /admin/
No module named 'DjangoProjects.Lunch'
But if I comment out the second url route in urls.py then it works. What is the correct way for me to import this module? Thanks.
urls.py:
from django.conf.urls import patterns, include, url
from django.contrib import admin
urlpatterns = patterns('',
# Examples:
# url(r'^$', 'DjangoProjects.views.home', name='home'),
# url(r'^blog/', include('blog.urls')),
url(r'^admin/', include(admin.site.urls)),
url(r'^lunch/$', 'DjangoProjects.Lunch.views.index')
)
views.py
from django.shortcuts import render
# Create your views here.
from django.shortcuts import render_to_response
def index(request):
return render_to_response('index.html')
index.html
hello world!
settings.py
"""
Django settings for DjangoProjects project.
For more information on this file, see
https://docs.djangoproject.com/en/dev/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/dev/ref/settings/
"""
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/dev/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'd^d9v4j(1maq-&_8^a+kgicmagxwbv*9m$!2st&vqz$5_h$441'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
TEMPLATE_DEBUG = True
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'Lunch',
'django.contrib.admin',
)
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 = 'DjangoProjects.urls'
WSGI_APPLICATION = 'DjangoProjects.wsgi.application'
# Database
# https://docs.djangoproject.com/en/dev/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
# Internationalization
# https://docs.djangoproject.com/en/dev/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/dev/howto/static-files/
STATIC_URL = '/static/'
Replace that line with :
url(r'^lunch/$', 'Lunch.views.index')
There is no need to specify the name of the project. You should start from the app name.
Also, make sure Lunch is in the INSTALLED_APPS in the settings file.