Anonymous committed 223ed09

settings: Remove hard-coded absolute paths

This is so that you don't have to change a dozen variables when you
deploy an instance somewhere other than on /srv/patchwork.

Signed-off-by: Guilherme Salgado <>
Signed-off-by: Jeremy Kerr <>

Comments (0)

Files changed (2)

 # Django settings for patchwork project.
+import os
 DEBUG = True
 # to load the internationalization machinery.
 USE_I18N = True
-# Absolute path to the directory that holds media.
-# Example: "/home/media/"
-MEDIA_ROOT = '/srv/patchwork/lib/python/django/contrib/admin/media'
 # URL that handles the media served from MEDIA_ROOT.
 # Example: ""
 LOGIN_URL = '/accounts/login'
+# If you change the ROOT_DIR setting in your, you'll need to
+# re-define the variables that use this (MEDIA_ROOT and TEMPLATE_DIRS) too.
+ROOT_DIR = '/srv/patchwork'
     # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
     # Always use forward slashes, even on Windows.
     # Don't forget to use absolute paths, not relative paths.
-    '/srv/patchwork/templates'
+    os.path.join(ROOT_DIR, 'templates')
+# Absolute path to the directory that holds media.
+# Example: "/home/media/"
+MEDIA_ROOT = os.path.join(
+    ROOT_DIR, 'lib', 'python', 'django', 'contrib', 'admin', 'media')
 # along with Patchwork; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+import os
 from django.conf.urls.defaults import *
 from django.conf import settings
 from patchwork.admin import admin_site
 from registration.views import register
 from patchwork.forms import RegistrationForm
+htdocs = os.path.join(settings.ROOT_DIR, 'htdocs')
 urlpatterns = patterns('',
     # Example:
     (r'^', include('patchwork.urls')),
      (r'^admin/(.*)', admin_site.root),
      (r'^css/(?P<path>.*)$', 'django.views.static.serve',
-        {'document_root': '/srv/patchwork/htdocs/css'}),
+        {'document_root': os.path.join(htdocs, 'css')}),
      (r'^js/(?P<path>.*)$', 'django.views.static.serve',
-        {'document_root': '/srv/patchwork/htdocs/js'}),
+        {'document_root': os.path.join(htdocs, 'js')}),
      (r'^images/(?P<path>.*)$', 'django.views.static.serve',
-        {'document_root': '/srv/patchwork/htdocs/images'}),
+        {'document_root': os.path.join(htdocs, 'images')}),
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.