Use MEDIA_URL in 500 error page

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
# views.py
from django.conf import settings
from django.template import Context, loader

def server_error(request, template_name='500.html'):
    "Always includes MEDIA_URL"
    from django.http import HttpResponseServerError
    t = loader.get_template(template_name)
    return HttpResponseServerError(t.render(Context({'MEDIA_URL': settings.MEDIA_URL})))

# urls.py
handler500 = 'views.server_error'

More like this

  1. Load static media from secure (SSL) static server (Context Processor) by ianreardon 3 years, 7 months ago
  2. Cycling MEDIA_URL context processor by girasquid 4 years, 5 months ago
  3. Use MEDIA_URL in flatpages with SSL by gobble 2 years, 10 months ago
  4. media_url context variable by marchino 6 years, 1 month ago
  5. HTTPS redirections middleware with updated URL template tag by xlq 7 months ago

Comments

(Forgotten your password?)