Ask jinja if a profile exists

How can I check if the object in profile model does not exist in the database, the crearprofile button appears and if it exists, profile appears?

{% if user.profile.is_defined %}
<a class="nav-link" href="{% url 'profile' %}">Perfil</a>
{% else %}                  
<a class="nav-link" href="{% url 'crearprofile' %}">Crear perfil</a>
{% endif %}

enter image description here

Maybe you can create a computed property on User model:

class User(models.Model):
    # some fields

    # some methods

    def profile(self):
            return Profile.objects.get(user=self)
            return None

Then on Jinja template only check

{% if user.profile %}
Back to Top