I have a page where users can search for other users. The search is done with ajax and the results are looped through in a template and then placed onto the page. The search works perfectly, but MEDIA_URL is showing up empty in the results and breaks all the profile pictures for the results. The MEDIA_URL tag works everywhere else on the site, just not in this template. I am using pyjade for my templates.
python to return results at end of search
#render template to string, pass to js to add to page
r = render_to_string('users/search_ajax_template.jade', { 'results': p })
return HttpResponse(json.dumps({'results': r, 'errcode': 0}))
search_ajax_template.jade
- for result in results
div.result-wrapper
a(href='/profiles/{{ result.path }}', class='result')
img(src='{{ MEDIA_URL }}{{ result.prof_pic }}')
div.result-name {{ result.name }}