V
V
vhsporno2019-05-21 12:17:52
Django
vhsporno, 2019-05-21 12:17:52

How to combine url and created template tag?

There is such a custom template tag for getting Person.id by User.id

def get_user(username):
  user = User.objects.get(username__iexact=username)
  per = Person.objects.get(user_id=user.id) 
  perid = per.id
  return perid
register.filter('get_user', get_user)

We call it in the template like this. There is a link in the form:
{{user|get_user}}
path('profile/<int:users_id>', views.profileuser, name='profileuser'),

The point is to make a link like this:
{% url 'index:profileuser' и тут вызвать кастомный темплейт тэг, что бы получить айди персона%}

How to implement it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
vhsporno, 2019-05-21
@vhsporno

Everything was solved very easily, I refused the custom template tag. called like this{% url 'index:profileuser' user.person.id %}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question