fluent_pages.views

All views of the CMS

The CurrentPageMixin class

class fluent_pages.views.CurrentPageMixin

Access the current page. This can be used for views which are defined as page type views in PageTypePlugin.urls.

The template context will have the same variables as the regular page templates would have, which are: * page * site * FLUENT_PAGES_BASE_TEMPLATE

get_context_data(**kwargs)

Add the plugin context to the template.

get_current_page()

Return the current page.

get_view_url()

When using the ViewUrlMixin.view_url_name feature of django-parler, this makes sure that mounted pages are also supported.

It uses fluent_pages.urlresolvers.mixed_reverse() function to resolve the view_url_name.

The CurrentPageTemplateMixin class

class fluent_pages.views.CurrentPageTemplateMixin

Automaticaly reuse the template of the current page for the URL pattern view.

get_template_names()

Auto-include the template of the CMS page.

The RobotsTxtView class

class fluent_pages.views.RobotsTxtView(**kwargs)

Exposing a robots.txt template in the Django project.

Add this view to the urls.py:

from fluent_pages.views import RobotsTxtView

urlpatterns = [
    # ...

    url(r'^robots.txt$', RobotsTxtView.as_view()),
]

Naturally, this pattern should be placed outside i18n_patterns() as it should appear at the top level.

A robots.txt template is included by default, which you have override in your own project. Possible templates could look like:

Simple:

Sitemap: {{ ROOT_URL }}sitemap.xml
{% if ROBOTS_TXT_DISALLOW_ALL %}
User-agent: *
Disallow: /
{% endif %}

Sitemaps per language for usage with i18n_patterns():

{% for language in language_codes %}Sitemap: {{ ROOT_URL }}{{ language }}/sitemap.xml
{% endfor %}

Alternative:

{% for sitemap_url in sitemap_urls %}Sitemap: {{ sitemap_url }}
{% endfor %}
get_i18n_patterns_codes()

Return the possible values that i18n_patterns() support.

get_sitemap_urls(root_url)

Return all possible sitemap URLs, which the template can use.

has_i18n_patterns_urls()

Check whether something like i18n_patterns() is used.

render_to_response(context, **response_kwargs)

Return a response, using the response_class for this view, with a template rendered with the given context.

Pass response_kwargs to the constructor of the response class.

content_type = 'text/plain'

The content_type to return.

template_name = 'robots.txt'

The template to render. You can override this template.