Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Update to Django 1.2 (and some other newer versions) and some other m…

…inor settings tweaks
  • Loading branch information...
commit e1ae6b6e786c5932cddc206be12420c08b583657 1 parent 69f2c33
@SmileyChris SmileyChris authored
View
4 django_startproject/project_template/myproject/conf/common/urls/admin.py
@@ -1,10 +1,8 @@
-from django.conf.urls.defaults import *
+from django.conf.urls.defaults import patterns, include
from django.contrib import admin
-
admin.autodiscover()
-
urlpatterns = patterns('',
(r'^admin/doc/', include('django.contrib.admindocs.urls')),
(r'^admin/', include(admin.site.urls)),
View
14 django_startproject/project_template/myproject/conf/dev/settings.py
@@ -5,7 +5,13 @@
ROOT_URLCONF = 'myproject.conf.dev.urls'
-# DATABASE_ENGINE = 'postgresql_psycopg2'
-# DATABASE_NAME = 'myproject'
-# DATABASE_USER = 'dbuser'
-# DATABASE_PASSWORD = 'dbpassword'
+MEDIA_ROOT = os.path.join(VAR_ROOT, 'uploads')
+
+DATABASES = {
+ 'default': {
+ 'ENGINE': 'django.db.backends.postgresql_psycopg2',
+ 'NAME': 'myproject',
+# 'USER': 'dbuser',
+# 'PASSWORD': 'dbpassword',
+ }
+}
View
2  django_startproject/project_template/myproject/conf/dev/urls.py
@@ -4,7 +4,7 @@
CONF_MODULE = '%s.conf' % settings.PROJECT_MODULE_NAME
urlpatterns = patterns('',
+ (r'', include('%s.urls' % CONF_MODULE)),
(r'', include('%s.common.urls.admin' % CONF_MODULE)),
(r'', include('%s.common.urls.static' % CONF_MODULE)),
- (r'', include('%s.urls' % CONF_MODULE)),
)
View
13 django_startproject/project_template/myproject/conf/local/example/settings.py
@@ -8,11 +8,12 @@
)
MANAGERS = ADMINS
-DATABASE_ENGINE = 'sqlite3'
-# Place the SQLite database into ``[project]/conf/local/`` so it's outside of
-# the repository.
-DATABASE_NAME = os.path.join(PROJECT_ROOT, PROJECT_MODULE_NAME,
- 'conf', 'local', 'dev.db')
+DATABASES = {
+ 'default': {
+ 'ENGINE': 'django.db.backends.sqlite3',
+ 'NAME': os.path.join(VAR_ROOT, 'dev.db'),
+ }
+}
ROOT_URLCONF = '%s.conf.local.urls' % PROJECT_MODULE_NAME
@@ -20,3 +21,5 @@
'django.contrib.admin',
'django.contrib.admindocs',
)
+
+MEDIA_ROOT = os.path.join(VAR_ROOT, 'uploads')
View
5 django_startproject/project_template/myproject/conf/settings.py
@@ -8,6 +8,8 @@
PROJECT_ROOT, PROJECT_MODULE_NAME = os.path.split(
os.path.dirname(os.path.realpath(myproject.__file__))
)
+# This assumes the project is installed in the src directory of a virtualenv.
+VAR_ROOT = os.path.join(os.path.dirname(os.path.dirname(PROJECT_ROOT)), 'var')
DEBUG = True
TEMPLATE_DEBUG = DEBUG
@@ -31,10 +33,7 @@
ADMIN_MEDIA_PREFIX = '/admin-media/'
MEDIA_URL = '/uploads/'
-MEDIA_ROOT = os.path.join(PROJECT_ROOT, 'uploads')
-
STATIC_URL = '/static/'
-STATIC_ROOT = os.path.join(PROJECT_ROOT, PROJECT_MODULE_NAME, 'static')
@mlouro Owner
mlouro added a note

any reason to remove STATIC_ROOT entirely? Can we have a default value there?

@SmileyChris Owner

I removed it due to the potential confusion about STATIC_ROOT being a collection point rather than a point where project-wide media should be installed (in the latest staticfiles iteration anyway).

Next step is to change the requirement to the new staticfiles version which mirrors Django 1.3 contrib.staticfiles. At that stage, we should be encouraging the use of STATICFILES_DIRS and django-staticfiles>=1.0.X

@SmileyChris Owner

But yes, we should probably make STATIC_ROOT = os.path.join(VAR_ROOT, 'static')

@mlouro Owner
mlouro added a note

so we should also have something like:

PROJECT_STATIC_ROOT = os.path.join(PROJECT_ROOT, PROJECT_MODULE_NAME, 'static')
STATICFILES_DIRS = (PROJECT_STATIC_ROOT,)

right?

@SmileyChris Owner

Yep, except I don't think the requirements are using staticfiles >= 1 yet. And I don't think I'd bother with PROJECT_STATIC_ROOT -- it just adds to the confusion between STATIC_ROOT being a collection point and this one being an endpoint.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
ROOT_URLCONF = 'myproject.conf.urls'
View
16 django_startproject/project_template/myproject/conf/test/settings.py
@@ -1,14 +1,16 @@
from myproject.conf.settings import *
-DEBUG=False
-TEMPLATE_DEBUG=False
-
-# Database connection info.
-DATABASE_ENGINE = 'sqlite3' # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
-DATABASE_NAME = ':memory:' # Or path to database file if using sqlite3.
+DEBUG = False
+TEMPLATE_DEBUG = DEBUG
+DATABASES = {
+ 'default': {
+ 'ENGINE': 'django.db.backends.sqlite3',
+ 'NAME': ':memory:',
+ }
+}
ROOT_URLCONF = 'myproject.conf.test.urls'
-INSTALLED_APPS += ('django_nose', )
+INSTALLED_APPS += ('django_nose',)
TEST_RUNNER = 'django_nose.NoseTestSuiteRunner'
Please sign in to comment.
Something went wrong with that request. Please try again.