mirror of
https://github.com/django/django.git
synced 2025-11-01 20:31:40 +00:00
Fixed #17529 -- get_template_from_string default arguments break
``get_template_from_string`` default arguments were breaking ``assertTemplateUsed``. The solution has been to return only the names of the templates with a ``name`` attribute distinct of ``None``. The default ``name`` kwarg of ``Template`` has been changed to ``None``, more pythonic than ``'<Unknown Template>'``.
This commit is contained in:
parent
bc21e9c0d9
commit
72f63bd24d
5 changed files with 16 additions and 3 deletions
|
|
@ -1,5 +1,6 @@
|
|||
from django.http import HttpResponse
|
||||
from django.shortcuts import get_object_or_404
|
||||
from django.template import loader, Context
|
||||
|
||||
from .models import Person
|
||||
|
||||
|
|
@ -7,3 +8,7 @@ from .models import Person
|
|||
def get_person(request, pk):
|
||||
person = get_object_or_404(Person, pk=pk)
|
||||
return HttpResponse(person.name)
|
||||
|
||||
def no_template_used(request):
|
||||
template = loader.get_template_from_string("This is a string-based template")
|
||||
return HttpResponse(template.render(Context({})))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue