djangosnippets.org: Latest snippets tagged with 'static-media'http://djangosnippets.org/tags/static-media/2008-08-16T07:31:12.375403-05:00Serve static media and indexes from app directories [Python2.5, Development only]
2008-08-16T07:31:12.375403-05:00adamloftshttp://djangosnippets.org/snippets/985/<p>This view serves static media and directory indexes for a django application. It should only be used in development, media should be provided directly by a web server in production.</p>
<p>This view assumes a django application stores its media in app/media (which is very common) and the file is referred …</p>
Freely redistributableServe static media files from app/media subdirectory
2008-08-05T04:55:12.342785-05:00adamloftshttp://djangosnippets.org/snippets/943/<p>This view will serve media files from all media subdirectories of apps in your INSTALLED_APPS setting. Save the view as media.py in your django site folder and add to urls.py:</p>
<pre><code>if settings.DEBUG:
urlpatterns += patterns('',
(r'^media/(?P<appname>\w+)/(?P<path>.+)$', 'devel_site.media.serve_apps')
)`
</code></pre>
<p>Now suppose your installed apps setting looks like:
INSTALLED_APPS = ('org.myself.myapp', ...) …</p>
Freely redistributable