[Answer]-Django media_url with ajax

1👍

Need to add MEDIA_URL to the context dictionary for rendering.

Option 1:

from django.template import RequestContext
...
...
...
r = render_to_string('users/search_ajax_template.jade', { 'results': p }, context_instance=RequestContext(request))

Option 2:

from settings import MEDIA_URL
...
...
...
r = render_to_string('users/search_ajax_template.jade', { 'results': p, 'MEDIA_URL': MEDIA_URL })

Leave a comment