-
Website
http://bart.whahay.net -
Original page
http://bart.whahay.net/2008/10/03/two-simple-techniques-to-make-your-django-projects-ultra-portable/ -
Subscribe
All Comments -
Community
-
Top Commenters
-
individual health insurance,
1 comment · 1 points
-
bmcvn
1 comment · 1 points
-
Bartek
19 comments · 3 points
-
spaetzel
3 comments · 1 points
-
SmileyChris
2 comments · 2 points
-
-
Popular Threads
ROOT_DIR = os.path.join(os.path.dirname(__file__))uses join incorrectly. The point of os.path.join is to join path components in a generic way that works across operating systems: Here's what you should use:PROJECT_ROOT = os.path.dirname(__file__)MEDIA_ROOT = os.path.join(PROJECT_ROOT, 'media')
And a tip for your urls.py for nicely serving static files in development mode:
# Static mediaimport sys
if 'runserver' in sys.argv:
----from django.conf import settings
----urlpatterns += patterns('django.views.static',
--------(r'^%s(?P<path>.*)' % settings.MEDIA_URL[1:], 'serve', {'document_root': settings.MEDIA_ROOT}),
----)
Edit: indented with dashes to preserve spacing
course use it from now on :)
os.path.join