[Fixed]-Django – if instance == 'userabc':

1👍

When you print something, Python calls its string representation, which in this case is “userabc”. But that doesn’t make the instance actually equal to that value: obviously it’s not, it’s a model instance not a string. You should compare the model attribute that is being used to generate the strong representation.

Leave a comment