settings.DEBUG in templates

1 view
Skip to first unread message

Tom Badran

unread,
Mar 13, 2008, 9:01:41 PM3/13/08
to Django users
Is there anything i can check using an 'if' templatetag that reflects the DEBUG setting in my settings.py, and if not is there an easy way i can add something that adds it to all templates, without me having to modify all my views?

Basically, im just trying to conditionally have the firebug lite javascript console included in my base template only when running in debug mode.

Thanks

Tom

Malcolm Tredinnick

unread,
Mar 13, 2008, 9:07:25 PM3/13/08
to django...@googlegroups.com

This is possible without any modifications. See

http://www.djangoproject.com/documentation/templates_python/#django-core-context-processors-debug

The debug context processor is one of the default ones, so if you
haven't changed anything, it should Just Work(tm).

Malcolm

--
Despite the cost of living, have you noticed how popular it remains?
http://www.pointy-stick.com/blog/

Tom Badran

unread,
Mar 14, 2008, 6:24:35 AM3/14/08
to django...@googlegroups.com
On Fri, Mar 14, 2008 at 1:07 AM, Malcolm Tredinnick <mal...@pointy-stick.com> wrote:


On Fri, 2008-03-14 at 01:01 +0000, Tom Badran wrote:
> Is there anything i can check using an 'if' templatetag that reflects
> the DEBUG setting in my settings.py, and if not is there an easy way i
> can add something that adds it to all templates, without me having to
> modify all my views?
>
> Basically, im just trying to conditionally have the firebug lite
> javascript console included in my base template only when running in
> debug mode.

This is possible without any modifications. See

       http://www.djangoproject.com/documentation/templates_python/#django-core-context-processors-debug

The debug context processor is one of the default ones, so if you
haven't changed anything, it should Just Work(tm).

Brilliant, i just needed to add an INTERNAL_IPS setting and now it does exactly what i want. Thanks for the pointer.

Tom

--
Tom Badran
http://badrunner.net

gabriel

unread,
Mar 14, 2008, 3:37:38 PM3/14/08
to django...@googlegroups.com
Hi,

I'd want to include back button into my web page so I need somehow to
read the value of url that I came from. This of course If django does
not provide any mechanism simplifying going back?

Do you know how to do it?

Than ks,
Gabriel

Tony Crockford

unread,
Mar 14, 2008, 2:47:39 PM3/14/08
to django...@googlegroups.com

if the browser back button isn't good enough and you really have to
have a back button in the page, this will work:

<form> <input type=button value="Back" onClick="history.back()"> </form>

;o)

--
Join me: http://wiki.workalone.co.uk/
Thank me: http://www.amazon.co.uk/gp/registry/1VK42TQL7VD2F
Engage me: http://www.boldfish.co.uk/portfolio/

Justin Lilly

unread,
Mar 14, 2008, 3:21:23 PM3/14/08
to django...@googlegroups.com
You can also apply that onclick property to links and such.

 -justin
--
Justin Lilly
Web Developer
Reply all
Reply to author
Forward
0 new messages