Re: get_object_or_404 hook

2011-06-09 Thread Jonathan Slenders
Indeed, this is nothing that has to be in the Django core. You can do something like this: http://dpaste.com/hold/552209/ Although, I do not think that's the best solution. By catching all DoesNotExist errors, the Django middleware will not receive the exception anymore and exception logging fram

Re: get_object_or_404 hook

2011-06-03 Thread Luke Plant
On 03/06/11 03:31, waylybaye wrote: > Hi guys, how about add a hook to get_object_or_404 to render a > template with the same name of model when object does not exist ? > > For example: > user = get_object_or_404(User, pk=pk) > > if the user does not exist, get_object_or_404 will try to render "

Re: get_object_or_404 hook

2011-06-03 Thread waylybaye
Yes, I always use a try block to give some error messages or render an error template. I can do it with a simple helper method . I just think it may be useful for others :) 2011/6/3 Justin Holmes > For every convenience method, there are always ways to make it even more > convenient. > > I thin

Re: get_object_or_404 hook

2011-06-02 Thread Vinicius Mendes
You can always create your own convenience method. Atenciosamente, Vinicius Mendes Engenheiro de Computação Globo.com On Fri, Jun 3, 2011 at 12:30 AM, Justin Holmes wrote: > For every convenience method, there are always ways to make it even more > convenient. > > I think that if the needs are

Re: get_object_or_404 hook

2011-06-02 Thread Justin Holmes
For every convenience method, there are always ways to make it even more convenient. I think that if the needs are other than the very most typical use case (ie, get_object_or_404) than a try block is indicated. On Thu, Jun 2, 2011 at 10:31 PM, waylybaye wrote: > Hi guys, how about add a hook t

get_object_or_404 hook

2011-06-02 Thread waylybaye
Hi guys, how about add a hook to get_object_or_404 to render a template with the same name of model when object does not exist ? For example: user = get_object_or_404(User, pk=pk) if the user does not exist, get_object_or_404 will try to render "404/ user.html" to show the error page other than