Trouble comparing variables in a view
I have attempted to troubleshoot this myself with no luck and am very
confused why a simple IF statement is not working. I have used if
statements in python before and never had such a problem. I am rather
glad to see that PRINT outputs to the console, this helps a bit for
troubleshooting. Variable information:
client_id = Comes in from a views request... def
view_client(request,client_id):
c.id = Comes in from a database model.
-- code --
print "%s - %s" % (str(client_id),str(c.id))
if str(client_id) == str(c.id):
-- end --
The console output, displays 3 - 3 as plain as a day, this is why I am
very confused on why it is not resolving. The logic always resolves
as False, which should resolve as True. I came to the conclusion that
both objects were different by using dir() and printing it out to the
console, hence the reason I now placed both objects inside a str() in
hopes it may work, but alas, it does not. If I put it as 3 == 3, it
resolves as True. Any ideas? Placed in str() along with dir(), both
objects are now equal, but the IF statement sees otherwise.
--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home