diff options
author | Akihiro Motoki <amotoki@gmail.com> | 2017-06-21 13:54:19 +0000 |
---|---|---|
committer | Akihiro Motoki <amotoki@gmail.com> | 2017-06-21 19:32:03 +0000 |
commit | 0c836454b26e0756131ce4b5f3ae312651da9d32 (patch) | |
tree | db2fd889fd2a91ead519f81a54729df2a40cacbf /horizon/browsers | |
parent | 4a882c14b99c811822d84a0b30d590ffa9023e4f (diff) | |
download | horizon-0c836454b26e0756131ce4b5f3ae312651da9d32.tar.gz |
Switch render() arguments to the new way
Previously template.render() takes Context or RequestContext object
but after Django 1.8 the method takes a dict and request as separate
arguments. The old way will be dropped in Django 1.10.
This commit update the usage based on the Django 1.8 release notes [1].
commit 95d78a140fdb6f24dc3bd87d654e9f927ddfbfa4 addresses this
deprecations but it turns out all similar places are not switched.
I searched the code base more carefully and found more.
I hope this clean up all of them.
After this change, extra_context which was passed to (Request)Context
previously is no longer available in HttpResponse object.
Volume unit test is tightly coupled with the context information
and checks rendered actions using the context. Thus the corresponding
tests no longer work. Since we can use only HttpResponse.content
(which is a rendered HTML), the new tests just check various strings
like ID, link and label of a specific action.
This is tricky, but this is now the only thing we can do.
[1] https://docs.djangoproject.com/en/1.8/ref/templates/upgrading/#get-template-and-select-template
Change-Id: I350c22dc3d7db7b93ca4b823dac1e3d88beef1a7
Diffstat (limited to 'horizon/browsers')
-rw-r--r-- | horizon/browsers/base.py | 3 | ||||
-rw-r--r-- | horizon/browsers/breadcrumb.py | 3 |
2 files changed, 2 insertions, 4 deletions
diff --git a/horizon/browsers/base.py b/horizon/browsers/base.py index 5a28c6797..907428c89 100644 --- a/horizon/browsers/base.py +++ b/horizon/browsers/base.py @@ -144,5 +144,4 @@ class ResourceBrowser(html.HTMLElement): def render(self): browser_template = template.loader.get_template(self.template) extra_context = {self.context_var_name: self} - context = template.RequestContext(self.request, extra_context) - return browser_template.render(context) + return browser_template.render(extra_context, self.request) diff --git a/horizon/browsers/breadcrumb.py b/horizon/browsers/breadcrumb.py index f4e13c556..567da56e5 100644 --- a/horizon/browsers/breadcrumb.py +++ b/horizon/browsers/breadcrumb.py @@ -42,5 +42,4 @@ class Breadcrumb(html.HTMLElement): """Renders the table using the template from the table options.""" breadcrumb_template = template.loader.get_template(self.template) extra_context = {"breadcrumb": self} - context = template.RequestContext(self.request, extra_context) - return breadcrumb_template.render(context) + return breadcrumb_template.render(extra_context, self.request) |