Reputation: 137
In my template, i want detect if the user connected is an traveller or admin. This is an example of my model. Note: User class is user django model class
I see "has_perm" but I haven't got permissions I want roles.
"is_authenticated()" but user admin and user traveller are authenticate.
"is_superuser" but i don't want many super user django admin
I used in spring the tag "hasRole('Admin') but in django i don't see the alternative.
Thanks!!
Upvotes: 0
Views: 1311
Reputation: 13731
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
Upvotes: 1