Note that there are some explanatory texts on larger screens.

plurals
  1. PODjango: serving ADMIN media files
    text
    copied!<p>I've been successfully serving media files for the normal MEDIA files, but when I tried serving admin media files, I failed. please kindly help me locating the problem, as I've tried to troubleshoot the problem for several hours already with no luck (been googling too and read the django doc about serving static files as well).</p> <p>The error as I tried to access localhost:8000/media/a.gif is as following:</p> <blockquote> <p>Page not found: f:\python25\lib\site-packages\django/contrib/admin/media\a.gif</p> </blockquote> <p>I put the admin media files in directory named "media", while I put the normal media files in directory named "static". I'm on Windows, too.</p> <p>Here's how I serve the ordinary media files in urls.py:</p> <pre><code># serve static files from django.conf import settings if settings.ENVIRONMENT==settings.ENV_DEVELOPMENT: urlpatterns += patterns("django.views", url(r"%s(?P&lt;path&gt;.*)$" % settings.MEDIA_URL[1:], "static.serve", {"document_root": settings.MEDIA_ROOT,}) ) </code></pre> <p>And my settings.py (only the important pieces):</p> <pre><code>import project_path MEDIA_ROOT = project_path.MEDIA.replace('\\','/') MEDIA_URL = '/static/' ADMIN_MEDIA_PREFIX = '/media/' TEMPLATE_DIRS = ( project_path.TEMPLATE.replace('\\','/'), ) </code></pre> <p>And my project_path.py:</p> <pre><code>import sys from os.path import dirname, join ROOT = dirname(__file__) APP = join(ROOT, "apps") TEMPLATE = join(ROOT, "templates") MEDIA = join(ROOT, "static") ADMIN_MEDIA = join(ROOT, "media") </code></pre> <p>Any hints?</p> <p>or maybe at least please share how do you serve your admin media files (without changing any files from the web server, but only via the django source code)</p> <p>Thanks in advance :)</p>
 

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