implement custom template view, add docs for it
This commit is contained in:
parent
efd4f79ef9
commit
c0cb56a97d
@ -216,6 +216,29 @@ Note: it is advised that you keep local customizations to a minimum as if you
|
||||
override builtin templates with your customized copies, you will have to keep
|
||||
your copies in sync with future changes we make to the builtin ones.
|
||||
|
||||
Custom templates
|
||||
----------------
|
||||
|
||||
If you need to add some simple views, just showing some simple templates (like
|
||||
e.g. if you have some footer links that link to these views to show some site-
|
||||
specific content, some legalese, ...), do it like that:
|
||||
|
||||
* have a footer and a custom template directory like described in previous
|
||||
section
|
||||
* add files like main/custom/foo.html to that directory::
|
||||
|
||||
{% extends "base.html" %}
|
||||
{% load bootstrap %}
|
||||
{% block content %}
|
||||
This is content rendered from template "foo.html".
|
||||
{% endblock %}
|
||||
|
||||
* link to the view made from that template like this::
|
||||
|
||||
<a href="{% url 'custom' template='foo.html' %}">
|
||||
link to custom foo.html view
|
||||
</a>
|
||||
|
||||
|
||||
Maintenance
|
||||
===========
|
||||
|
@ -8,7 +8,7 @@ from django.views.generic import TemplateView
|
||||
from .views import (
|
||||
HomeView, OverviewView, HostView, DeleteHostView, AboutView, GenerateSecretView, GenerateNSSecretView,
|
||||
RobotsTxtView, DomainOverviewView, DomainView, DeleteDomainView, StatusView, JsUpdateView,
|
||||
UpdaterHostConfigOverviewView, UpdaterHostConfigView, DeleteUpdaterHostConfigView)
|
||||
UpdaterHostConfigOverviewView, UpdaterHostConfigView, DeleteUpdaterHostConfigView, CustomTemplateView)
|
||||
from ..api.views import (
|
||||
myip_view, DetectIpView, AjaxGetIps, NicUpdateView, AuthorizedNicUpdateView,
|
||||
NicDeleteView, AuthorizedNicDeleteView)
|
||||
@ -19,6 +19,7 @@ urlpatterns = patterns(
|
||||
# interactive web ui
|
||||
url(r'^$', HomeView.as_view(), name="home"),
|
||||
url(r'^about/$', AboutView.as_view(), name="about"),
|
||||
url(r'^custom/(?P<template>[\w.]+)$', CustomTemplateView.as_view(), name="custom"),
|
||||
url(r'^update$', JsUpdateView.as_view(), name='update'),
|
||||
url(r'^overview/$', OverviewView.as_view(), name='overview'),
|
||||
url(r'^host/(?P<pk>\d+)/$', HostView.as_view(), name='host_view'),
|
||||
|
@ -80,6 +80,14 @@ class AboutView(TemplateView):
|
||||
return context
|
||||
|
||||
|
||||
class CustomTemplateView(TemplateView):
|
||||
# template_name is set in dispatch method
|
||||
|
||||
def dispatch(self, *args, **kwargs):
|
||||
self.template_name = 'main/custom/%s' % kwargs.get('template')
|
||||
return super(CustomTemplateView, self).dispatch(*args, **kwargs)
|
||||
|
||||
|
||||
class HomeView(TemplateView):
|
||||
template_name = "main/home.html"
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user