Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3227556
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T16:35:19+00:00 2026-05-17T16:35:19+00:00

I have a development server running (and serving content) using the built in django

  • 0

I have a development server running (and serving content) using the built in django server. All my templates that are rendered from generic views point correctly to the static media files (css/java/imgs) but ones that are rendered via custom views don’t seem to prepend the /media/ folder to the urls. (At least this seems to be the problem)

In my settings I have:

DJANGO_PATH = os.path.realpath(os.path.dirname(__file__))
DB_PATH = os.path.join( (os.path.split(DJANGO_PATH))[0] , 'db/dev.db')
TEMPLATE_PATH = os.path.join( DJANGO_PATH , 'templates')
DEBUG = True
TEMPLATE_DEBUG = DEBUG

MEDIA_PATH = os.path.join( (os.path.split(DJANGO_PATH))[0] , 'media')
ADMIN_MEDIA_PREFIX = '/media/admin/'
MEDIA_URL = '/media/'
MEDIA_ROOT = MEDIA_PATH

and In my urls I have an entry

(r'^media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT, 'show_indexes': True }),

Anyone got any ideas?

EDIT:
Ooops, forgot to mention. All my templates inherit from a base template which has all the media files like:

{{ MEDIA_URL }}css/some/file.css

So in my templates folder I have:

/templates/base.html
/templates/someapp/childtemplate.html

with all the css/js in the header like above. Then in the templates specific to my applicaiton I am simply inheriting the base template

Furthermore
I can view the media by visiting

localhost:8000/media/  

no problem, so the urlCONF seems to be doing it’s job

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T16:35:20+00:00Added an answer on May 17, 2026 at 4:35 pm

    If I’m not mistaken, MEDIA_URL is not accessible by default from the template context.
    The easiest workaround is to create a new template context processor:

    def media_url(request):
        from django.conf import settings
        return {'media_url': settings.MEDIA_URL} 
    

    And in settings.py:

    TEMPLATE_CONTEXT_PROCESSORS = ('myapp.context_processors.media_url',)
    

    Just remember to use the RequestContext when rendering the template. In the view:

    from django.template import RequestContext
    return render_to_response("my_app/my_template.html", {'some_var': 'foo'}, context_instance=RequestContext(request))
    

    Your templates should now render correctly.

    For more on this:
    http://www.b-list.org/weblog/2006/jun/14/django-tips-template-context-processors/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a app that I'm deploying to a development server using Capistrano. I'd
I have a development vm which is running sql server as well as some
I have a database table on a development server that is now fully populated
I have found many tutorials about using Windows Server 2003 as a development machine,
I can't access externally to python development server, I have a very small django
I have make one site using Zend Framework. Its working fine in development server
I have CruiseControl.NET Version 1.4 set up on my development server. Whenever a developer
I want to make a development server for Ruby. (I have done this for
I have somewhat interesting development situation. The client and deployment server are inside a
I have two SQL Server 2005 databases, one is for development and the other

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.