Login

Tag "404"

Snippet List

Flatpage Suggester Template tag for 404 templates

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. For example, if the URL that resulted in a 404 was: /foo/bar/baz/whatever/ This tag would look for FlatPages whose URL starts with the following: /foo/bar/baz/whatever/ /foo/bar/baz/ /foo/bar/ /foo/

  • template-tag
  • flatpage
  • 404
  • suggestion
Read More

URL models

You can use `UrlModel` 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. `class Page(UrlModel): text = models.TextField() def view(self, request) # do something here return HttpResponse(...)`

  • middleware
  • urls
  • models
  • foreignkey
  • model
  • generic
  • url
  • foreign-key
  • genericforeignkey
  • contenttypes
  • 404
  • contenttype
  • content-type
Read More

View decorator to convert DoesNotExist (ObjectDoesNotExist) exceptions into Http404 exceptions

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. Example: @raise_404 def show_event(request, id): event = Event.objects.get(id) return render_to_response('events/show_event.html', { 'event' : event })

  • error
  • exception
  • 404
  • errors
  • exceptions
  • objectdoesnotexist
  • doesnotexist
Read More

4 snippets posted so far.