mirror of
https://github.com/postgres/pgweb.git
synced 2025-08-10 00:42:06 +00:00
Add function to render a template to a string
This commit is contained in:
@ -1,6 +1,8 @@
|
||||
from django.shortcuts import render_to_response, get_object_or_404
|
||||
from pgweb.util.contexts import NavContext
|
||||
from django.http import HttpResponseRedirect
|
||||
from django.template import Context
|
||||
from django.template.loader import get_template
|
||||
|
||||
def simple_form(instancetype, itemid, request, formclass, formtemplate='base/form.html', redirect='/account/', navsection='account'):
|
||||
if itemid == 'new':
|
||||
@ -41,6 +43,9 @@ def simple_form(instancetype, itemid, request, formclass, formtemplate='base/for
|
||||
'form_intro': hasattr(form, 'form_intro') and form.form_intro or None,
|
||||
}, NavContext(request, navsection))
|
||||
|
||||
def template_to_string(templatename, attrs = {}):
|
||||
return get_template(templatename).render(Context(attrs))
|
||||
|
||||
def add_xml_element(xml, name, value):
|
||||
xml.startElement(name, {})
|
||||
xml.characters(value)
|
||||
|
Reference in New Issue
Block a user