Question: **Background:** 

I'm starting to use Django for the first time, which is also my first foray into web development. I just got stuck on the whole "serving static media" problem. After spending a while looking at all the documentation and StackOverflow questions, I think I understand how it's supposed to work (i.e. MEDIA\_ROOT, MEDIA\_URL, updating the urls file, etc).

**My Question**: 

Ok, so here's the part I'm not sure about. Django applications are supposed to be "pluggable", i.e. I can move an application from one project to another. So, how should these applications bundle static media?

For example, let's say I have a "foo" application, which has templates that load some css/image files. Where am I supposed to put these files, so that they'll automatically get served once I include the application?

The only solution I see, is that installing an application has to include the extra step of copying its static media to some place on your own server that serves that media.

Is this the accepted way to do it? It includes an extra step, but maybe that's standard when dealing with web-dev (I'm new so I don't really know).

Also, if this is the way, is there a standard way to collect all my static media to make it easy to know what I need to serve? (I.e., is it standard to have a folder named "media" or something inside the app?).

Thanks,

Answer: 
Convention is to put static media in either media/appname/ or static/appname/ within the app (similar to templates).

For using apps in your project that come with media, I strongly recommend using [django-staticfiles](http://pypi.python.org/pypi/django-staticfiles). It will automatically serve media (including media within apps) in development through a view that replaces django.views.static.serve, and it comes with a build\_static management command that will copy media from all apps into a single directory for serving in production.

**Update**: django-staticfiles has [become part of Django 1.3](http://docs.djangoproject.com/en/dev/howto/static-files/). It now expects app media to live in a "static/" subdirectory of the app, not "media/". And the management command is now "collectstatic."
The only app I know of that deals with this without any intervention is the rather wonderful [django-debug-toolbar](http://github.com/robhudson/django-debug-toolbar), though it's arguable that this isn't a great example, since it's an app specifically designed for debug mode only.

The way it deals with it is that it serves its media through Django itself - see the source for [urls.py](http://github.com/robhudson/django-debug-toolbar/blob/master/debug_toolbar/urls.py):

```
url(r'^%s/m/(.*)$' % _PREFIX, 'debug_toolbar.views.debug_media'),

```

In general, this is a bad idea (you don't want to serve static files through Django), per [this comment from the documentation](http://docs.djangoproject.com/en/dev/howto/static-files/):

> 
> [Serving static files through Django] is inefficient and
>  insecure. Do not use this in a
>  production setting. Use this only for
>  development.
> 
> 
> 

Obviously, the django-debug-toolbar is only used for development, so I think its method of deployment makes sense, but this is very much an exception.

In general, the best way I know to do it is to create symbolic links wherever your media is stored to the media inside your app code. For example, create a folder called `media` within your app, and then require users installing your app to either add a symbolic link from their media directory, or copy the whole thing.