mercredi 15 juillet 2020

Compare Django model field and request.user.username in HTML

I want to compare two string. One from the request.user.username, and the other is from the model's attribute (field). When I print them like



I see the same two strings, like

Chris
Chris

but if I use the


    They are the same!

it doesn't work, the HTML page says they are two different strings. Why?

The one from the model:

EgysegVezeto = models.CharField(max_length=255, default='', verbose_name="Egység vezetője")

and the other:

class Profile(models.Model):
    user = models.OneToOneField(User, on_delete=models.CASCADE)
    def __str__(self):
        return str(self.user.last_name + " " + self.user.first_name)

Aucun commentaire:

Enregistrer un commentaire