title: How to display custom 404.html page in Django
body: <p>I want to display a custom 404 error page when an end user enters a wrong url. I have tried but I am only getting the Django default 404 page. I am using Python 2.7.5 and Django 1.5.4.</p>
  
  <p>My Code:</p>
  
  <p><code>urls.py</code></p>
  
  <pre><code>from django.conf.urls import patterns, include, url
  from mysite import views
  handler404 = views.error404
  
  urlpatterns = patterns('',
  url(r'^$', 'mysite.views.home', name='home'),
  )
  </code></pre>
  
  <p><code>views.py</code></p>
  
  <pre><code>from django.http import HttpResponse
  from django.shortcuts import render
  from django.template import Context, loader
  
  def home(request):
       return HttpResponse("welcome to my world")
  
  def error404(request):
       template = loader.get_template('404.html')
       context = Context({'message': 'All: %s' % request,})
       return HttpResponse(content=template.render(context), content_type='text/html; charset=utf-8', status=404)
  </code></pre>
  
  <p>I have placed my <code>404.html</code> page in templates directory. How to handle this?</p>