0

so there is this IF statement inside a html file , which is failing to return a TRUE when both the strings are the same , i dont know why , i copy pasted the same strings from database to another python compiler and it said TRUE but it is only failing here I will add a sscreenshot of a reverse case where i will print it if they are not equal so you can see the string and confirm enter image description here

this is the printed ones , i currently have 2 comments in my database

enter image description here

here it prints for both case ,hence shows how both strings are not same for both cases

im using django

one of the fields is a CharField with max length of 500 and another (post_id = models.CharField(max_length=500))

another is a uuid field (id = models.UUIDField(primary_key=True, default=uuid.uuid4))

i tried is instead of == , still fails im expecting it to only return a TRUE if both strings are equal ( please ignore the != in screenshot as it is just to print out the strings)

1 Answers1

0

{% if post.id|stringformat:"s" == comments.post_id %} this solved it , thanks

  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Aug 20 '23 at 08:02