title: Django 3.x - Custom Error Page is showing a 500 when it should be a 404
body: <p>UPDATE: Added the code I was accessing that threw the error</p>
  <p>For a CS50 project I'm working on with a wiki page, I'm trying to send the right custom 404 error when a user types a page that doesn't exist in wiki/TITLE however when I type a missing page, Django throws a 500 instead of a 404. Is this a common error or did I make my error message wrong? Debug is set to False and Allowed Hosts is configured to ['*'] in settings:</p>
  <p>Here's my custom error handlers in views.py:</p>
  <pre><code>def error_404(request, exception):
      context = {}
      response = render(request, 'encyclopedia/error_404.html', context=context)
      response.status_code = 404
      return response
  
  
  def error_500(request):
      context = {}
      response = render(request, 'encyclopedia/error_500.html', context=context)
      response.status_code = 500
      return response
  </code></pre>
  <p>Here's how they are in wiki/urls.py:</p>
  <pre><code>from django.contrib import admin
  from django.urls import include, path
  from django.conf.urls import handler404, handler500
  
  urlpatterns = [
      path('admin/', admin.site.urls),
      path('', include(&quot;encyclopedia.urls&quot;)),
  ]
  
  handler404 = &quot;encyclopedia.views.error_404&quot;
  handler500 = &quot;encyclopedia.views.error_500&quot;
  </code></pre>
  <p>here's the function in views.py that I'm accessing but going to wiki/C:</p>
  <pre><code>#function gets entry from index.html's &lt;li&gt;
  def entry_page(request, entry):
      name = entry                     # Places the title       
      print(f&quot;checking the title: {entry}&quot;)                            
      text = util.get_entry(entry)     # Grabs the entry using the util function
      html = md_converter(text)  
  
      if text is not None:
          return render(request, &quot;encyclopedia/entry.html&quot;, {
              &quot;title&quot;: name,
              &quot;entry&quot;: html
          })
  </code></pre>
  <p>And here's my urls.py for good measure:</p>
  <pre><code>from django.urls import path
  
  from . import views
  
  app_name = &quot;encyclopedia&quot;
  urlpatterns = [
      path(&quot;&quot;, views.index, name=&quot;index&quot;),
      path(&quot;wiki/&lt;str:entry&gt;&quot;, views.entry_page, name=&quot;entry&quot;),
      path(&quot;wiki/edit/&lt;str:title&gt;&quot;, views.edit, name=&quot;edit&quot;),
      path(&quot;search&quot;, views.search, name=&quot;search&quot;),
      path(&quot;random&quot;, views.random_page, name=&quot;random&quot;),
      path(&quot;create_entry&quot;,views.create_entry, name=&quot;create_entry&quot;)
  ]
  </code></pre>
  <p>Here's what the terminal shows (my styles.css is throwing a 404 for some reason but I haven't changed anything there...that's a separate issue):
  <a href="https://i.stack.imgur.com/LuKx0.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LuKx0.png" alt="my terminal when I go to a page that isn't there" /></a></p>