permissions in the Django template

Asked

Viewed 9 times

-1

I’m trying to create a permission in the Django template but I couldn’t. Wanted to set in the template only professional users to view a button.

This is the professional model I’m creating.

class Profissional(models.Model):
            profissao = models.CharField('Profissão', max_length=250)
            categoria = models.ManyToManyField(Categoria)
            slug = models.SlugField('Atalho', unique=True, blank=True, null=True)
            descricao = models.CharField('Descrição', max_length=250)
            imagem = models.ImageField(upload_to='fotos/%Y/%m/', blank=True, null=True)
            user = models.OneToOneField(Usuario, on_delete=models.CASCADE, related_name='usario')
            acesso =  models.BooleanField(default=True)

defined in the model a boolean field of access equal to true, in my template I am trying to do the check so that only professionals see the button but it is not appearing to any user this way.

{% if user.profissional.acesso  %}

Someone can tell me a hint?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.