Django for Designers/Adding models: Difference between revisions

→‎Dealing with errors: HTTP error, not HTML error
imported>Paulproteus
(Revert change for now; we'll fix the pedagogy problem a different way)
imported>Paulproteus
(→‎Dealing with errors: HTTP error, not HTML error)
Line 737:
tag = Tag.objects.get(slug=tag_name)</source>
 
Fortunately, Django has a shortcut function that can help us -- get_object_or_404(). This function will attempt to get a Django model based on the parameters you give it, and if it fails, automatically throw ana HTMLstandard 404HTTP "not found" error, number 404.
 
<source lang="python">
Anonymous user