>
> Thanks. The technical aspects go a bit above my head but this is a good 
> post for me to bookmark and use as a jumping off point for some reading.
>
> After switching out .first() but before adding the 404 redirect I was 
> getting a   '<type 'exceptions.AttributeError'> 'NoneType' object has no 
> attribute 'title'' error. The error ticket wasn't overly helpful on this 
> one. Is this due to other issues with my terrible noob code?
>

When you try a postid that doesn't exist, the select with .first() will 
return None rather than a Rows object, so the value of "post" that you 
return to the view is None. I assume your view must do something like 
post.title, but since post is None, that results in an AttributeError. To 
avoid that, you should either make sure the controller redirects or raises 
a 404 when the post doesn't exist (so it never gets to the view), or 
include logic in the view to check whether post is None (i.e., {{if 
post:}}) and don't show the post record in that case.

Anthony

Reply via email to