1
1
101-s2020-05-19 13:58:51
Django
101-s, 2020-05-19 13:58:51

How to call a user in Dzhang and attach meta tags to him?

The question is rather broader, how to do meta tags correctly? Are there methods already implemented in the engine?

I decided to do it like this (I need the output of a metatitle, description, h1 in the application responsible for authentication and displaying a personal account ), in the model:

from django.contrib.auth.models import User

class MyUser(User):
    def name(self):
        if not User.first_name:
            return "Юзер %s" % User.id
        return User.first_name
    
    def meta_title(self):
        return "Cтраница пользователя %s" % self.name

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dr. Bacon, 2020-05-19
@101-s

In the template itself

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question