Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Straight from the comments in settings.py...</p> <h3>MEDIA_ROOT</h3> <p>The <code>MEDIA_ROOT</code> is the absolute path to the directory that holds media such as <code>/home/media/media.lawrence.com/</code>. </p> <h3>MEDIA_URL</h3> <p>The <code>MEDIA_URL</code> is the URL that handles the media served from <code>MEDIA_ROOT</code>. Make sure to use a trailing slash if there is a path component (optional in other cases). Examples: "<a href="http://media.lawrence.com" rel="noreferrer">http://media.lawrence.com</a>", "<a href="http://example.com/media/" rel="noreferrer">http://example.com/media/</a>".</p> <p>So, to reword those... The <code>MEDIA_ROOT</code> is where the files live physically on your system, and the <code>MEDIA_URL</code> is where those files are mapped to. In development, this might not always be accessible, and in most cases your dev environment and your production environment are not the same, and it is something you're going to have to go back and change. The other thing is that it is NOT A GOOD PRACTICE when Django was designed NOT to serve static content for you. </p> <p>If you're going to use this in development, I suggest you use the method of <a href="http://docs.djangoproject.com/en/1.1/howto/static-files/#limiting-use-to-debug-true" rel="noreferrer">limiting it to DEBUG=True</a>. Telling Django to serve static content from a temporary location while in development when the <code>DEBUG</code> is set to <code>True</code> is a much better and safer practice. You're NOT going to put your site into production with <code>DEBUG</code> on, right? Well, at least you shouldn't.</p> <p>Here is how I implemented it:</p> <p>settings.py:</p> <pre><code>STATIC_DOC_ROOT = os.path.join(os.getcwd(), 'site_media') </code></pre> <p>urls.py:</p> <pre><code>from django.conf import settings ## debug stuff to serve static media if settings.DEBUG: urlpatterns += patterns('', (r'^site_media/(?P&lt;path&gt;.*)$', 'django.views.static.serve', {'document_root': settings.STATIC_DOC_ROOT}), ) </code></pre> <p>This way any project I'm working on has a <code>site_media</code> directory inside of it with all of the media necessary. In dev it is self-contained and I don't have to flip any bits in the settings except for <code>DEBUG</code>, which I would be doing anyways. </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload