Well the first suspicious thing was that you were testing to see if it
was equal to the string "0".  That tells me you don't understand how
equality works in python.  Python is strongly typed.  Strings and
integers are not the same thing, and will never be equal to one another.
Without more information, we can't really tell what's going on.

Also, if you are expecting the string "Enabled" or "Disabled" to be
passed in to the template, you are overcomplicating things by saying

  {% if EnableLogUpload == "Enabled" %}Enabled{% else %}Disabled{% endif
%}

You could just say

  {{ EnableLogUpload }}

But none of that will solve your problem, because EnableLogUpload is
clearly not set to the string "Enabled".  I can say for sure that you're
passing it in wrong from the view, but I can't say how without seeing
your view code. Please share that as well.

If I were doing it from scratch, I would just make a the EnableLogUpload
variable a boolean, and worry about how I want to render it in the
template.  I would also use standard python naming conventions (because
the most important task of code is to communicate with other
programmers, and only secondarily to make a computer do things).  The
simplified version would look like this:

=== views.py ===

def view(request):
    context = {'enable_log_upload': True}
    return render('template.html', context)

=== end views.py ===

=== template.html ===

{% if enable_log_upload %}enabled{% else %}disabled{% endif %}

=== end template.html ===

Note that I'm not trying to test if enable_log_upload is equal to
anything in particular.  I just want to know if it's a true value or
not.


On Fri, 2012-03-16 at 07:47 -0700, HarryBoy wrote:
> 
> If I set it to "Enabled" and then check if it is indeed {% if
> EnableLogUpload == "Enabled" %} it does not enter the if statement.
> 
> 
> What am I doing wrong??
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/x6xX1B-NbYcJ.
> 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.


-- 
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