Electronics & Programming

develissimo

Open Source electronics development and programming

  • You are not logged in.

#1 Dec. 13, 2010 09:00:25

P.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

default_if_none as settings (??)


Maybe I'm wrong but I remember about a setting whose I don't remember
the name...acting like a default for default_if_none where
default_if_none was not used.

Example:
{{ value }} <-- I forgot about using the "default_if_none" filter

If the setting I'm talking about is defined then its value is used
instead of "None" as string, if value is None.

I haven't found any information about that setting in the current
documentation. If I really used that setting in the past, it was in
the 0.95/0.96 version.

Thank you for your help.

P.S. If the setting doesn't exist, how can I achive the same result
without using "default_if_none" everywhere?

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

Offline

#2 Dec. 13, 2010 12:15:54

Brad R.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

default_if_none as settings (??)


If I understand correctly, then the solution would be to do something of
this sort: (pardon the formatting)

if value:
{{value}}
else:
{{default_value}}

Something of that sort *should* work, although I am not entirely sure.

On Mon, Dec 13, 2010 at 4:00 AM, PyMan <claudio.marino...@rsoft.it> wrote:

> Maybe I'm wrong but I remember about a setting whose I don't remember
> the name...acting like a default for default_if_none where
> default_if_none was not used.
>
> Example:
> {{ value }} <-- I forgot about using the "default_if_none" filter
>
> If the setting I'm talking about is defined then its value is used
> instead of "None" as string, if value is None.
>
> I haven't found any information about that setting in the current
> documentation. If I really used that setting in the past, it was in
> the 0.95/0.96 version.
>
> Thank you for your help.
>
> P.S. If the setting doesn't exist, how can I achive the same result
> without using "default_if_none" everywhere?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com<django-users%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
>http://groups.google.com/group/django-users?hl=en.
>
>

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

Offline

#3 Dec. 13, 2010 13:15:59

bruno d.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

default_if_none as settings (??)


On 13 déc, 10:00, PyMan <claudio.marino...@rsoft.it> wrote:
> Maybe I'm wrong but I remember about a setting whose I don't remember
> the name...acting like a default for default_if_none where
> default_if_none was not used.
>
> Example:
> {{ value }}  <-- I forgot about using the "default_if_none" filter

You're possibly thinking of TEMPLATE_STRING_IF_INVALID:http://docs.djangoproject.com/en/1.2/ref/settings/#template-string-if-invalidbut IIRC it won't work like this:

> If the setting I'm talking about is defined then its value is used
> instead of "None" as string, if value is None.
>

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

Offline

#4 Dec. 13, 2010 13:16:56

bruno d.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

default_if_none as settings (??)


On 13 déc, 13:15, Brad Reardon <bradsq...@gmail.com> wrote:
> If I understand correctly, then the solution would be to do something of
> this sort: (pardon the formatting)
>
> if value:
>     {{value}}
> else:
>     {{default_value}}


You may want to read about the builtin "default" and "default_if_none"
template filters ;)

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

Offline

#5 Dec. 13, 2010 13:30:26

P.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

default_if_none as settings (??)


Oohh yes! That is what I was looking for. Still thanks!
As you said it's not working exactly how I use to rememeber...but it's
ok! :)

On 13 Dic, 14:15, bruno desthuilliers <bruno.desthuilli...@gmail.com>
wrote:
> On 13 déc, 10:00, PyMan <claudio.marino...@rsoft.it> wrote:
>
> > Maybe I'm wrong but I remember about a setting whose I don't remember
> > the name...acting like a default for default_if_none where
> > default_if_none was not used.
>
> > Example:
> > {{ value }}  <-- I forgot about using the "default_if_none" filter
>
> You're possibly thinking of TEMPLATE_STRING_IF_INVALID:
>
>http://docs.djangoproject.com/en/1.2/ref/settings/#template-string-if...
>
> but IIRC it won't work like this:
>
> > If the setting I'm talking about is defined then its value is used
> > instead of "None" as string, if value is None.

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

Offline

Board footer

Moderator control

Enjoy the 12th of December
PoweredBy

The Forums are managed by develissimo stuff members, if you find any issues or misplaced content please help us to fix it. Thank you! Tell us via Contact Options
Leave a Message
Welcome to Develissimo Live Support