Permalink
Browse files

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

…inor settings tweaks
  • Loading branch information...
1 parent 69f2c33 commit e1ae6b6e786c5932cddc206be12420c08b583657 @SmileyChris SmileyChris committed Oct 27, 2010
@@ -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)),
@@ -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',
+ }
+}
@@ -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)),
)
@@ -8,15 +8,18 @@
)
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
INSTALLED_APPS += (
'django.contrib.admin',
'django.contrib.admindocs',
)
+
+MEDIA_ROOT = os.path.join(VAR_ROOT, 'uploads')
@@ -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
mlouro Feb 24, 2011 Owner

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

SmileyChris
SmileyChris Feb 24, 2011 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
SmileyChris Feb 24, 2011 Owner

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

mlouro
mlouro Feb 24, 2011 Owner

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
SmileyChris Feb 24, 2011 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.

ROOT_URLCONF = 'myproject.conf.urls'
@@ -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'

0 comments on commit e1ae6b6

Please sign in to comment.