Here are the examples of the python api django.template.loader.get_template taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
370 Examples
3
Source : views.py
with GNU General Public License v3.0
from 41xu
with GNU General Public License v3.0
from 41xu
def chart(request):
if request.method=="POST":
appid=int(request.POST.get('appid'))
template=loader.get_template('chart.html')
age_pie=calage(appid)
gender_pie=calgender(appid)
context=dict(
host=REMOTE_HOST,
myechart_gender=gender_pie.render_embed(),
script_list_gender=gender_pie.get_js_dependencies(),
myechart_age=age_pie.render_embed(),
script_list_age=age_pie.get_js_dependencies()
)
return HttpResponse(template.render(context,request))
return render_to_response('chart.html')
def line3d():
3
Source : filters.py
with GNU General Public License v3.0
from abaoMAO
with GNU General Public License v3.0
from abaoMAO
def __str__(self):
tpl = get_template(self.template)
return mark_safe(tpl.render(context=self.get_context()))
class FieldFilterManager(object):
3
Source : admin_list.py
with GNU General Public License v3.0
from Aghoreshwar
with GNU General Public License v3.0
from Aghoreshwar
def admin_list_filter(cl, spec):
tpl = get_template(spec.template)
return tpl.render({
'title': spec.title,
'choices': list(spec.choices(cl)),
'spec': spec,
})
@register.inclusion_tag('admin/actions.html', takes_context=True)
3
Source : defaults.py
with GNU General Public License v3.0
from Aghoreshwar
with GNU General Public License v3.0
from Aghoreshwar
def server_error(request, template_name=ERROR_500_TEMPLATE_NAME):
"""
500 error handler.
Templates: :template:`500.html`
Context: None
"""
try:
template = loader.get_template(template_name)
except TemplateDoesNotExist:
if template_name != ERROR_500_TEMPLATE_NAME:
# Reraise if it's a missing custom template.
raise
return HttpResponseServerError(' < h1>Server Error (500) < /h1>', content_type='text/html')
return HttpResponseServerError(template.render())
@requires_csrf_token
3
Source : views.py
with GNU General Public License v3.0
from Aghoreshwar
with GNU General Public License v3.0
from Aghoreshwar
def index(request):
context ={}
template = loader.get_template("userdata/index.html")
return HttpResponse(template.render(context, request))
def help(request):
3
Source : views.py
with GNU General Public License v3.0
from Aghoreshwar
with GNU General Public License v3.0
from Aghoreshwar
def help(request):
context ={}
template = loader.get_template("userdata/help.html")
return HttpResponse(template.render(context, request))
def update_table(dtype,request):
3
Source : admin_list.py
with MIT License
from Air-999
with MIT License
from Air-999
def admin_list_filter(cl, spec):
tpl = get_template(spec.template)
return tpl.render({
'title': spec.title,
'choices': list(spec.choices(cl)),
'spec': spec,
})
def admin_actions(context):
3
Source : build_solr_schema.py
with GNU General Public License v3.0
from ajslater
with GNU General Public License v3.0
from ajslater
def build_template(self, using, template_filename=schema_template_loc):
t = loader.get_template(template_filename)
c = self.build_context(using=using)
return t.render(c)
def print_stdout(self, schema_xml):
3
Source : diy_widgets.py
with MIT License
from allwaysLove
with MIT License
from allwaysLove
def render(self, name, value, attrs=None, renderer=None):
context = self.get_context(name, value, attrs)
template = loader.get_template(self.template_name).render(context)
return mark_safe(template)
class UploadModel(models.Model):
3
Source : panel.py
with BSD 3-Clause "New" or "Revised" License
from andytwoods
with BSD 3-Clause "New" or "Revised" License
from andytwoods
def nav_subtitle(self):
"""
Show abbreviated name of view function as subtitle
"""
match = resolve(self.toolbar.request.path)
func, args, kwargs = match
view_name = get_name_from_obj(func)
template = loader.get_template('mrbenn_panel/mrbenn_title.html')
context = {
'template_name': self.templates[0]["template"].name if self.templates else '',
'view_name': view_name,
}
return mark_safe(template.render(context=context))
template = "mrbenn_panel/mrbenn_panel.html"
3
Source : views.py
with BSD 3-Clause "New" or "Revised" License
from andytwoods
with BSD 3-Clause "New" or "Revised" License
from andytwoods
def _retrieve_template_name(request):
template_name = request.GET.get('template')
template = get_template(template_name)
return template.origin.name
def open_template(request):
3
Source : filters.py
with Apache License 2.0
from aphp
with Apache License 2.0
from aphp
def to_html(self, request, queryset, view):
if not getattr(view, 'search_fields', None):
return ''
term = self.get_contains_terms(request)
term = term[0] if term else ''
context = {
'param': self.search_param,
'term': term
}
template = loader.get_template(self.template)
return template.render(context)
def get_schema_fields(self, view):
3
Source : bad_request_view.py
with Apache License 2.0
from appheap
with Apache License 2.0
from appheap
def bad_request(request, exception, template_name=ERROR_400_TEMPLATE_NAME):
try:
template = loader.get_template(template_name)
except TemplateDoesNotExist:
if template_name != ERROR_400_TEMPLATE_NAME:
# Reraise if it's a missing custom template.
raise
return HttpResponseBadRequest(
ERROR_PAGE_TEMPLATE % {'title': 'Bad Request (400)', 'details': ''},
content_type='text/html',
)
# No exception content is passed to the template, to not disclose any sensitive information.
return HttpResponseBadRequest(template.render())
3
Source : permission_denied_view.py
with Apache License 2.0
from appheap
with Apache License 2.0
from appheap
def permission_denied(request, exception, template_name=ERROR_403_TEMPLATE_NAME):
try:
template = loader.get_template(template_name)
except TemplateDoesNotExist:
if template_name != ERROR_403_TEMPLATE_NAME:
# Reraise if it's a missing custom template.
raise
return HttpResponseForbidden(
ERROR_PAGE_TEMPLATE % {'title': '403 Forbidden', 'details': ''},
content_type='text/html',
)
return HttpResponseForbidden(
template.render(request=request, context={'exception': str(exception)})
)
3
Source : server_error_view.py
with Apache License 2.0
from appheap
with Apache License 2.0
from appheap
def server_error(request, template_name=ERROR_500_TEMPLATE_NAME):
try:
template = loader.get_template(template_name)
except TemplateDoesNotExist:
if template_name != ERROR_500_TEMPLATE_NAME:
# Reraise if it's a missing custom template.
raise
return HttpResponseServerError(
ERROR_PAGE_TEMPLATE % {'title': 'Server Error (500)', 'details': ''},
content_type='text/html',
)
return HttpResponseServerError(template.render())
3
Source : views.py
with GNU General Public License v3.0
from Archmonger
with GNU General Public License v3.0
from Archmonger
def simple_filter_modal(request):
content_type = request.GET.get("content_type")
if content_type == "tv":
filters = tv_filters().keys()
filter_url = reverse("discover:tv")
elif content_type == "movie":
filters = movie_filters().keys()
filter_url = reverse("discover:movies")
else:
filters = combined_filters().keys()
filter_url = reverse("discover:all")
context = {
"content_type": content_type,
"filters": filters,
"filter_url": filter_url,
}
template = loader.get_template("modal/discover_filter_simple.html")
return HttpResponse(template.render(context, request))
3
Source : views.py
with GNU General Public License v3.0
from Archmonger
with GNU General Public License v3.0
from Archmonger
def report_issue_modal(request):
# Get the parameters from the URL
context = {
"issues": ISSUE_LIST,
"tmdb_id": request.GET.get("tmdb_id", None),
"content_type": request.GET.get("content_type", None),
}
template = loader.get_template("modal/report_issue.html")
return HttpResponse(template.render(context, request))
@login_required
3
Source : views.py
with GNU General Public License v3.0
from Archmonger
with GNU General Public License v3.0
from Archmonger
def manage_modal(request):
template = loader.get_template("modal/manage_user.html")
username = request.GET.get("username", None)
user = None
try:
user = get_user_model().objects.get(username=username)
except Exception:
pass
context = {"account": user}
return HttpResponse(template.render(context, request))
3
Source : views.py
with GNU General Public License v3.0
from Archmonger
with GNU General Public License v3.0
from Archmonger
def collection(request):
collection_id = request.GET.get("collection_id", None)
if collection_id:
content_discovery = TmdbDiscovery()
tmdb_collection = content_discovery.collections(collection_id)
if not isinstance(tmdb_collection, dict) or not tmdb_collection:
tmdb_collection = None
else:
set_many_availability(tmdb_collection["parts"])
context = {"collection": tmdb_collection}
template = loader.get_template("viewport/components/more_info_collection.html")
return HttpResponse(template.render(context, request))
3
Source : views.py
with GNU General Public License v3.0
from Archmonger
with GNU General Public License v3.0
from Archmonger
def server_settings(request):
template = loader.get_template("viewport/server_settings.html")
context = {"os_platform": platform()}
return HttpResponse(template.render(context, request))
def radarr_settings(request):
3
Source : views.py
with MIT License
from Areesha-Tahir
with MIT License
from Areesha-Tahir
def homeadmin(request):
template = loader.get_template("homeadmin.html")
# passing dictionary will help us inject data to our webpage
return HttpResponse(template.render({}, request))
def homefdo(request):
3
Source : views.py
with MIT License
from Areesha-Tahir
with MIT License
from Areesha-Tahir
def homefdo(request):
template = loader.get_template("homefdo.html")
# passing dictionary will help us inject data to our webpage
return HttpResponse(template.render({}, request))
def login(request):
3
Source : views.py
with MIT License
from Areesha-Tahir
with MIT License
from Areesha-Tahir
def login(request):
if(request.method == "POST"):
form = LoginForm(request.POST)
if form.is_valid():
actor = form.cleaned_data["Name"]
if(actor == "Admin"):
return render(request, "homeadmin.html", {"form": form})
elif(actor == "FDO"):
return render(request, "homefdo.html", {"form": form})
else:
form = LoginForm()
template = loader.get_template("accounts/login.html")
# passing dictionary will help us inject data to our webpage
return HttpResponse(template.render({"form": form}, request))
def AddNewEvent(request):
3
Source : views.py
with Apache License 2.0
from aropan
with Apache License 2.0
from aropan
def result(request, slug, name):
event = get_object_or_404(Event, slug=slug)
standings_urls = {s['name'].lower(): s['url'] for s in event.standings_urls}
url = standings_urls[name]
if url.startswith('http'):
return redirect(url)
template = get_template(url)
html = template.render()
return HttpResponse(html)
@permission_required('events.change_team')
3
Source : share_icon.py
with GNU General Public License v3.0
from artoonie
with GNU General Public License v3.0
from artoonie
def get_icon(shareTo):
""" Pass in the text label. Will return an image from /share_icons/ of the same name. """
shareToLower = shareTo.lower()
shareImageIconUrl = static(f'share/share_icons/{shareToLower}.png')
shareTemplate = loader.get_template('share/share_icon_tag.html')
context = {'shareImageIconUrl': shareImageIconUrl,
'shareToText': shareTo}
return shareTemplate.render(context)
3
Source : exceptions.py
with GNU General Public License v3.0
from auto-mat
with GNU General Public License v3.0
from auto-mat
def permission_denied_view(
request, exception, template_name=defaults.ERROR_403_TEMPLATE_NAME
):
if hasattr(exception, "template_name"):
template_name = exception.template_name
template = loader.get_template(template_name)
return HttpResponseForbidden(
template.render(
request=request,
context={
"fullpage_error_message": str(exception),
"fullpage_error_level": getattr(exception, "error_level", "danger"),
"title": getattr(exception, "title", _("Přístup odepřen")),
},
),
)
return defaults.permission_denied(request, exception, template_name)
3
Source : backends.py
with Apache License 2.0
from BeanWei
with Apache License 2.0
from BeanWei
def to_html(self, request, queryset, view):
filter_class = self.get_filter_class(view, queryset)
if not filter_class:
return None
filter_instance = filter_class(request.query_params, queryset=queryset, request=request)
template = loader.get_template(self.template)
context = {
'filter': filter_instance
}
return template.render(context, request)
def get_coreschema_field(self, field):
3
Source : filters.py
with Apache License 2.0
from BeanWei
with Apache License 2.0
from BeanWei
def to_html(self, request, queryset, view):
if not getattr(view, 'search_fields', None):
return ''
term = self.get_search_terms(request)
term = term[0] if term else ''
context = {
'param': self.search_param,
'term': term
}
template = loader.get_template(self.template)
return template.render(context)
def get_schema_fields(self, view):
3
Source : filters.py
with Apache License 2.0
from BeanWei
with Apache License 2.0
from BeanWei
def to_html(self, request, queryset, view):
template = loader.get_template(self.template)
context = self.get_template_context(request, queryset, view)
return template.render(context)
def get_schema_fields(self, view):
3
Source : pagination.py
with Apache License 2.0
from BeanWei
with Apache License 2.0
from BeanWei
def to_html(self):
template = loader.get_template(self.template)
context = self.get_html_context()
return template.render(context)
def get_schema_fields(self, view):
3
Source : renderers.py
with Apache License 2.0
from BeanWei
with Apache License 2.0
from BeanWei
def render(self, data, accepted_media_type=None, renderer_context=None):
if isinstance(data, coreapi.Document):
template = loader.get_template(self.template)
context = self.get_context(data, renderer_context['request'])
return template.render(context, request=renderer_context['request'])
else:
template = loader.get_template(self.error_template)
context = {
"data": data,
"request": renderer_context['request'],
"response": renderer_context['response'],
"debug": settings.DEBUG,
}
return template.render(context, request=renderer_context['request'])
class SchemaJSRenderer(BaseRenderer):
3
Source : renderers.py
with Apache License 2.0
from BeanWei
with Apache License 2.0
from BeanWei
def render(self, data, accepted_media_type=None, renderer_context=None):
codec = coreapi.codecs.CoreJSONCodec()
schema = base64.b64encode(codec.encode(data)).decode('ascii')
template = loader.get_template(self.template)
context = {'schema': mark_safe(schema)}
request = renderer_context['request']
return template.render(context, request=request)
class MultiPartRenderer(BaseRenderer):
3
Source : projectroles_common_tags.py
with MIT License
from bihealth
with MIT License
from bihealth
def template_exists(path):
"""Return True/False based on whether a template exists"""
try:
get_template(path)
return True
except template.TemplateDoesNotExist:
return False
@register.simple_tag
3
Source : views.py
with GNU Affero General Public License v3.0
from botshot
with GNU Affero General Public License v3.0
from botshot
def index(request):
context = {}
template = loader.get_template('botshot/index.html')
return HttpResponse(template.render(context,request))
@login_required(login_url=reverse_lazy('login'))
3
Source : views.py
with GNU Affero General Public License v3.0
from botshot
with GNU Affero General Public License v3.0
from botshot
def flows(request):
context = {
'flows': get_flows()
}
template = loader.get_template('botshot/flows.html')
return HttpResponse(template.render(context,request))
# TODO this really needs improvement
@login_required(login_url=reverse_lazy('login'))
3
Source : views.py
with GNU Affero General Public License v3.0
from botshot
with GNU Affero General Public License v3.0
from botshot
def test_recording(request):
recorded_yaml = ConversationTestRecorder.get_result_yaml()
context = {
'recorded_yaml': recorded_yaml
}
template = loader.get_template('botshot/test_recording.html')
return HttpResponse(template.render(context, request))
@login_required(login_url=reverse_lazy('login'))
3
Source : views.py
with GNU Affero General Public License v3.0
from botshot
with GNU Affero General Public License v3.0
from botshot
def log(request):
context = {}
template = loader.get_template('botshot/log.html')
return HttpResponse(template.render(context,request))
class StandardResultsSetPagination(pagination.PageNumberPagination):
3
Source : views.py
with MIT License
from CAU-OSS-2019
with MIT License
from CAU-OSS-2019
def index(request):
template = loader.get_template('mainapp/index.html')
context = {
'latest_question_list': "test",
}
return HttpResponse(template.render(context, request))
3
Source : __init__.py
with MIT License
from ChanTsune
with MIT License
from ChanTsune
def get_template_from_status_code(self, status_code, request=None):
message = STATUS_MESSAGES[status_code]
try:
if settings.DEBUG:
file_name = "boost/tecnical/base.html"
else:
file_name = "%s.html" % status_code
t = get_template(file_name)
context = {'status_code': status_code,
'status_message': message}
return t.render(context, request)
except TemplateDoesNotExist:
return "%s %s" % (status_code, message)
def process_exception(self, request, e):
3
Source : defaults.py
with MIT License
from chunky2808
with MIT License
from chunky2808
def server_error(request, template_name=ERROR_500_TEMPLATE_NAME):
"""
500 error handler.
Templates: :template:`500.html`
Context: None
"""
try:
template = loader.get_template(template_name)
except TemplateDoesNotExist:
if template_name != ERROR_500_TEMPLATE_NAME:
# Reraise if it's a missing custom template.
raise
return http.HttpResponseServerError(' < h1>Server Error (500) < /h1>', content_type='text/html')
return http.HttpResponseServerError(template.render())
@requires_csrf_token
3
Source : filters.py
with Apache License 2.0
from Code4PuertoRico
with Apache License 2.0
from Code4PuertoRico
def to_html(self, request, queryset, view):
search_term = self.get_search_term(request) or ""
template = loader.get_template(self.template)
return template.render({"param": self.search_param, "term": search_term})
def get_schema_operation_parameters(self, view):
3
Source : views.py
with MIT License
from codingforentrepreneurs
with MIT License
from codingforentrepreneurs
def example_page(request):
context = {"title": "Example"}
template_name = "hello_world.html"
template_obj = get_template(template_name)
rendered_item = template_obj.render(context)
return HttpResponse(rendered_item)
3
Source : views.py
with MIT License
from configcat
with MIT License
from configcat
def index(request):
template = loader.get_template('index.html')
return HttpResponse(template.render(request=request))
# 1. As the passed User's country is Hungary this will return 'Dog'.
def index1(request):
3
Source : utils.py
with MIT License
from davitovmasyan
with MIT License
from davitovmasyan
def render_body(template_name: str, context: dict = None) -> str:
"""
Load template by given name, pass it context
and render as a string.
"""
template = loader.get_template(template_name)
return template.render(context)
def send_email(
3
Source : login_user.py
with MIT License
from digitalfabrik
with MIT License
from digitalfabrik
def login_screen(request):
"""
Default login screen. Redirect if user is already
logged in.
"""
template = loader.get_template('login.html')
context = {
'latest_question_list': [],
# pylint: disable=E1101
'logos': Logo.objects.filter(main=False)
}
if request.user.is_authenticated:
return HttpResponseRedirect("/gui/news")
return HttpResponse(template.render(context, request))
@csrf_protect
3
Source : snippet.py
with Apache License 2.0
from dockerizeme
with Apache License 2.0
from dockerizeme
def setUp(self):
if self.patch_templates:
self.get_template = django.template.loader.get_template
def get_template(*args, **kwargs):
return Template("")
django.template.loader.get_template = get_template
if "django.contrib.sessions" in settings.INSTALLED_APPS:
# Workaround for https://code.djangoproject.com/ticket/15740
engine = import_module(settings.SESSION_ENGINE)
store = engine.SessionStore()
store.save()
self.client.cookies[settings.SESSION_COOKIE_NAME] = store.session_key
self.load_data()
def tearDown(self):
3
Source : services.py
with MIT License
from dtcooper
with MIT License
from dtcooper
def render_conf_file(self, filename, context=None, conf_filename=None):
default_context = {"settings": settings, "config": config}
if context is not None:
default_context.update(context)
template = get_template(f"services/{filename}")
conf = template.template.render(make_context(default_context, autoescape=False))
conf_filename = f"/config/{self.service_name}/{filename if conf_filename is None else conf_filename}"
os.makedirs(os.path.dirname(conf_filename), exist_ok=True)
with open(conf_filename, "w") as conf_file:
conf_file.write(conf)
logger.info(f"writing config file {conf_filename}")
def clear_supervisor_conf(self):
3
Source : views.py
with GNU General Public License v3.0
from dubs3c
with GNU General Public License v3.0
from dubs3c
def integration_detail(request, integration):
"""Render the specific integration page"""
if not integration.isalpha():
return HttpResponse("Can't find what you are looking for...", status=404)
try:
template = get_template(f"settings/{integration}.html")
except TemplateDoesNotExist:
return HttpResponse("Can't find what you are looking for...", status=404)
except TemplateSyntaxError:
LOGGER.error(f"Syntax error in template: {integration}")
return HttpResponse("This should not have happened", status=404)
return render(request, template.template.name)
def integration_telegram(request):
3
Source : views.py
with MIT License
from e-m-b-a
with MIT License
from e-m-b-a
def login(request):
html_body = get_template('uploader/login.html')
return HttpResponse(html_body.render())
def register(request):
3
Source : views.py
with MIT License
from e-m-b-a
with MIT License
from e-m-b-a
def register(request):
html_body = get_template('uploader/register.html')
return HttpResponse(html_body.render())
@login_required(login_url='/' + settings.LOGIN_URL)
See More Examples