Skip to content

Commit

Permalink
fix(3276): Use get_template()
Browse files Browse the repository at this point in the history
The `get_template()` call correctly fetches the template via the engine,
but to get the same template type as the one used in the other branch,
we need to access its template attribute, where the original template is
stored.

The engine template wrap the base template to allow direct
rendering by TemplateResponse, however this conflicts with the "template
via static files" approach taken by Strawberry.

Since I'm unfamiliar with the reasoning for this approach, we'll leave
it in tact.
  • Loading branch information
msopacua committed Dec 6, 2023
1 parent fce79ef commit 5c4686c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions strawberry/django/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from django.http.response import HttpResponse
from django.template import RequestContext, Template
from django.template.exceptions import TemplateDoesNotExist
from django.template.loader import render_to_string
from django.template.loader import get_template
from django.template.response import TemplateResponse
from django.utils.decorators import classonlymethod, method_decorator
from django.views.decorators.csrf import csrf_exempt
Expand Down Expand Up @@ -215,7 +215,7 @@ def dispatch(

def render_graphql_ide(self, request: HttpRequest) -> HttpResponse:
try:
template = Template(render_to_string("graphql/graphiql.html"))
template = get_template("graphql/graphiql.html").template
except TemplateDoesNotExist:
template = Template(self.graphql_ide_html)

Expand Down Expand Up @@ -274,7 +274,7 @@ async def dispatch( # pyright: ignore

async def render_graphql_ide(self, request: HttpRequest) -> HttpResponse:
try:
template = Template(render_to_string("graphql/graphiql.html"))
template = get_template("graphql/graphiql.html").template
except TemplateDoesNotExist:
template = Template(self.graphql_ide_html)

Expand Down

0 comments on commit 5c4686c

Please sign in to comment.