I159
I159

Reputation: 31139

Using upload_to with STATICFILES_DIRS

Is it necessary to appoint MEDIA_ROOT, if indicated STATICFILES_DIRS? This issue arose when loading images - upload_to formed using MEDIA_ROOT and ignores STATICFILES_DIRS. If actually did not necessarily how to use upload_to with STATICFILES_DIRS?

Upvotes: 1

Views: 647

Answers (1)

Johannes
Johannes

Reputation: 1608

Media and Static files might seem similar on first glance, but when you dig deeper you will find that Django draws a fine line between both. While Media usually refers to files uploaded by users, static files are created and bundled together with django apps.

The idea behind static files is, that upon release you can call

./manage.py collectstatic

and have all your static files from your apps (even 3rd party ones that live in egg files) collected into a given directory your HTTP server can serve directly (without any django/wsgi in the middle) for best performance.

The same holds true for Media files, but they are uploaded by users and not created by you or other app developers.

Hope that eases your confusion :-)

I recommend you take a look at the excellent documentation at the Django homepage:

Upvotes: 2

Related Questions