Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use_title_tag not work in MetadataMixin #90

Open
CleitonDeLima opened this issue May 17, 2019 · 5 comments
Open

use_title_tag not work in MetadataMixin #90

CleitonDeLima opened this issue May 17, 2019 · 5 comments

Comments

@CleitonDeLima
Copy link

Example:

class MyView(MetadataMixin, TemplateView):
    use_title_tag = True
    title = 'my title'

META_USE_TITLE_TAG in settings has preference

@yakky
Copy link
Member

yakky commented Jun 29, 2019

@CleitonDeLima as all the MetadataMixin are defined as instance attributes, they will take precedence over class attributes defined in the derived class. Use __init__ to set the desired values:

class MyView(MetadataMixin, TemplateView):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.use_title_tag = True
        self.title = 'my title'

@CleitonDeLima
Copy link
Author

@yakky Is the behavior supposed to be that way?
Would not it be better these instance attributes are class attributes too?

@yakky
Copy link
Member

yakky commented Jul 2, 2019

I agree there is room for improvements, but still the capability to define them at runtime must be preserved

I don't know when I will be able to handle this, though, if anyone wants to contribute a solution, I'll happily review the PR

@CleitonDeLima
Copy link
Author

I can help it, no problem :)

@yakky
Copy link
Member

yakky commented Jul 2, 2019

that would be awesome 🎉

Thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants