Hi folks,

We have a Menu model which defines a nullable field called Rel. The Menu
record is persisted via the admin site, and when the Rel textbox is left
blank, Django/ MySQL saves the field as null. When a template uses that Menu
object, it's Rel property is not seen as an empty string by the following
statement:

{{% if menu_item.rel != "None" or menu_item != "" %}}
*render something*
{{% endif %}}

Could it be that the template engine sees a Python None when it encounters
the string "None"?

Note: A way around this was to make the field not nullable in MySQL,
whereupon it's saved as an empty string.

Is there a method of avoiding the behaviour where empty strings are saved as
nulls in nullable MySQL fields?

Thanks.
-- 
Regards,
Sithembewena Lloyd Dube
http://www.lloyddube.com

-- 
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 at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to