Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Taking care of deprecation warning: 'render() must be called with a d…
…ict, not a Context.'
- Loading branch information
1 parent
e8bc9b6
commit 06b9d5c
Showing
4 changed files
with
41 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import django | ||
from django.template import Context | ||
|
||
|
||
if django.VERSION < (1, 8): | ||
def get_template(context, template_name): | ||
from django.template.loader import get_template | ||
return get_template(template_name) | ||
|
||
def get_context(context): | ||
# Django < 1.8 only wants ``Context`` instances as context, no dict | ||
# instances. | ||
if not isinstance(context, Context): | ||
return Context(context) | ||
return context | ||
|
||
else: | ||
def get_template(context, template_name): | ||
# Django 1.8 and higher support multiple template engines. We need to | ||
# load child templates used in the floppyform template tags from the | ||
# same engine. Otherwise this might get really confusing. | ||
return context.template.engine.get_template(template_name) | ||
|
||
def get_context(context): | ||
# Django 1.8 only wants dicts as context, no ``Context`` instances. | ||
return context |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{# A helper template used in the Form.as_* methods. #} | ||
{% load floppyforms %} | ||
{% form form using layout %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters