djangosnippets.org: Latest snippets tagged with '404'http://djangosnippets.org/tags/404/2010-08-06T18:45:03.991262-05:00Decorator for enabling views only when developing
2010-08-06T18:45:03.991262-05:00damdhttp://djangosnippets.org/snippets/2138/<p>This is a decorator which essentially replaces the decorated view with a view that always raises <code>Http404</code> (File Not Found) when <code>settings.DEBUG</code> is set to True.
</p>
Freely redistributableFlatpage Suggester Template tag for 404 templates
2010-02-02T10:13:41.545450-06:00bradmontgomeryhttp://djangosnippets.org/snippets/1908/<p>This template tag finds FlatPages with urls 'similar' to the given request_path. It takes the request_path from the page_not_found view (django.views.defaults), picks it apart, and attempts to match existing FlatPages that have a 'similar' URL.</p>
<p>For example, if the URL that resulted in a 404 was:</p>
<pre><code>/foo/bar/baz/whatever/
</code></pre>
<p>This tag would …</p>
Freely redistributableURL models
2009-10-09T18:11:07.721923-05:00divermanhttp://djangosnippets.org/snippets/1755/<p>You can use <code>UrlModel</code> to provide URL functionality to any instance of any model and any language (language support can be removed from this). Each model must have own view method, that returns HttpResponse. I was inspired by Flatpages. It is useful for small sites and static pages.</p>
<pre><code>`class Page(UrlModel): …</code></pre>
Freely redistributableView decorator to convert DoesNotExist (ObjectDoesNotExist) exceptions into Http404 exceptions
2009-09-26T03:58:57.691763-05:00jammycakeshttp://djangosnippets.org/snippets/1743/<p>A decorator that can be applied to your views to turn ObjectDoesNotExist exceptions into Http404 exceptions. This means people will see a "Page not found" error rather than an "Internal Server Error" when they are request something that does not exist in the database.
</p>
<p>Example:
</p>
<pre><code>@raise_404
def show_event(request, id):
event …</code></pre>
Freely redistributable