Skip to content

Commit 253c226

Browse files
committed
Adds media and static paths. Also, adds PROJECT_ROOT.
1 parent 2e1891a commit 253c226

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

pythonkc_site/settings.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
# Django settings for pythonkc_site project.
2-
32
import os
43

4+
5+
PROJECT_ROOT = os.path.abspath(os.path.dirname(__file__))
6+
57
DEBUG = True
68
TEMPLATE_DEBUG = DEBUG
79

@@ -14,7 +16,7 @@
1416
DATABASES = {
1517
'default': {
1618
'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
17-
'NAME': os.path.join(os.path.abspath(os.path.dirname(__file__)), 'pythonkc.sqlite'), # Or path to database file if using sqlite3.
19+
'NAME': os.path.join(PROJECT_ROOT, 'pythonkc.sqlite'), # Or path to database file if using sqlite3.
1820
'USER': '', # Not used with sqlite3.
1921
'PASSWORD': '', # Not used with sqlite3.
2022
'HOST': '', # Set to empty string for localhost. Not used with sqlite3.
@@ -47,18 +49,18 @@
4749

4850
# Absolute filesystem path to the directory that will hold user-uploaded files.
4951
# Example: "/home/media/media.lawrence.com/media/"
50-
MEDIA_ROOT = ''
52+
MEDIA_ROOT = os.path.join(PROJECT_ROOT, 'media'),
5153

5254
# URL that handles the media served from MEDIA_ROOT. Make sure to use a
5355
# trailing slash.
5456
# Examples: "http://media.lawrence.com/media/", "http://example.com/media/"
55-
MEDIA_URL = ''
57+
MEDIA_URL = '/media/'
5658

5759
# Absolute path to the directory static files should be collected to.
5860
# Don't put anything in this directory yourself; store your static files
5961
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
6062
# Example: "/home/media/media.lawrence.com/static/"
61-
STATIC_ROOT = ''
63+
STATIC_ROOT = os.path.join(PROJECT_ROOT, 'static'),
6264

6365
# URL prefix for static files.
6466
# Example: "http://media.lawrence.com/static/"
@@ -105,10 +107,7 @@
105107
ROOT_URLCONF = 'pythonkc_site.urls'
106108

107109
TEMPLATE_DIRS = (
108-
os.path.join(os.path.abspath(os.path.dirname(__file__)), 'templates'),
109-
# Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
110-
# Always use forward slashes, even on Windows.
111-
# Don't forget to use absolute paths, not relative paths.
110+
os.path.join(PROJECT_ROOT, 'templates'),
112111
)
113112

114113
INSTALLED_APPS = (

0 commit comments

Comments
 (0)