Django {{ MEDIA_URL }} blank @DEPRECATED

前端 未结 5 1856
不思量自难忘°
不思量自难忘° 2020-12-01 13:55

I have banged my head over this for the last few hours. I can not get {{ MEDIA_URL }} to show up

in settings.py

..
MEDIA_URL = \'http://10.10.0.106/a         


        
5条回答
  •  臣服心动
    2020-12-01 14:27

    You need to add the RequestContext in your render_to_response for the context processors to be processed.

    In your case:

    from django.template.context import RequestContext
    
    context = {'latest': p}
    render_to_response('Question/latest.html',
                       context_instance=RequestContext(request, context))
    

    From the docs:

    context_instance

    The context instance to render the template with. By default, the template will be rendered with a Context instance (filled with values from dictionary). If you need to use context processors, render the template with a RequestContext instance instead.

提交回复
热议问题