[Answer]-How detect role user in django template?

1👍

From what I understand you should be able to put static properties on the classes themselves to dictate whether they are an Administrator or a Traveller without the usage of isinstance.

class Administrator(User):
    ...

    @property
    def is_admin(self):
        return True

    @property
    def is_traveller(self):
        return False



class Traveller(User):
    ...

    @property
    def is_admin(self):
        return False

    @property
    def is_traveller(self):
        return True

Leave a comment