On Sat, Jul 21, 2012 at 10:09 AM, Masud Khokhar <masud.khok...@gmail.com> wrote:
> Hi all,
>
> I am using the default 404 view that Django uses. I have created a custom 
> 404.html page in my templates directory which automatically gets loaded. Is 
> it possible for this page to load a python dictionary or do I need to raise 
> http404 myself for that?
>
> In essence, what I am trying to do is load a random message in the 404.html. 
> There may be a simpler solution for that.

There sure is: Use a template tag instead.

https://docs.djangoproject.com/en/1.4/howto/custom-template-tags/#simple-tags

If your custom template tag makes the random call, you don't need to
put randomly selected text or a randomly selected value into the
template context.

The template context for the 404 page isn't something that's
configurable by default, so if you *did* want to go down that path,
you'd have to write your own 404 view, and set that as your 404
handler. This isn't especially difficult to do, but the template tag
approach will be simpler :-)

Yours,
Russ Magee %-)

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to