1
I was trying to create a permission for my template but I couldn’t. I did some research to know how to do it and I’m not getting it. basically would like a permission similar to what Django has for example the is_superuser.
in the template I can define that only super users can view the content.
{% if user.is_superuser %}
<p> Este código só pode ser visto por um super usuário.</p>
{% endif %}
this is what I use for super users but I want to make a specific type of user example:
class UserTecnico(models.Model):
user = models.OneToOneField(User, on_delete=models.CASCADE)
cpf = models.CharField(primary_key=True,max_length=11,blank=True)
SEXO_CHOICES = (
('M', 'Maculino'),
('F', 'Feminino'),
)
sexo = models.CharField(max_length=2,blank=True,choices=SEXO_CHOICES)
is_pode_acessar = models.BooleanField(default=True)
for example here I have a technical user with a boolean field "is_pode_access" the default is True but nothing happens in the template.
{% if UserTecnico.is_pode_acessar %}
<p> Este código só pode ser visto por um usuário técnico.</p>
{% endif %}
Can someone tell me how I do ?
Thank you! I’ll try.
– Cláudio guita
worked out the way you suggested thanks!
– Cláudio guita
Good! Mark the answer as right to be able to help others with the same question. Thank you
– afonso
but I don’t have enough points to score :/
– Cláudio guita