elkefreed
elkefreed

Reputation: 964

Django CMS Page Title Doesn't Render

I'm currently working on a project that uses django-registration and Django CMS. When display the pages that implement django-registration my page titles do not render.

Currently have <title>{% page_attribute page_title %}</title> in base.html which all my templates inherit from.

In the pages that do not use django-registration the titles display just fine, but django-registration display as <title></title>

My pages are all created within the CMS and everything else is rendering correctly. If I set the title explicitly within the template, the title will render, but I'd rather have it set within the CMS.

The relevant portion of registration_form.html is below:

{% extends "base.html" %}
{% load cms_tags %}
{% load i18n %}
{% block "html_headers" %}
   <!-- conditional stuff here -->
  <link href="/media/css/forms.css" rel="stylesheet" type="text/css" />
{% endblock %}

Thanks!

Upvotes: 9

Views: 4182

Answers (1)

ojii
ojii

Reputation: 4781

the {% page_attribute %} template tag only works on CMS pages. When in views controlled by django-registration, they will not work and rather return an empty string (since Django's template language should never raise exceptions on runtime). In the templates used by django-registration, you need to override the title tag.

Therefore I suggest you use <title>{% block title %}{% page_attribute page_title %}{% endblock %}</title> in your base template. Then in the registration template do something like {% block title %}Registration{% endblock %}.

Upvotes: 15

Related Questions