Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Deprecation warning in Django 1.9 #297

Merged
merged 1 commit into from Feb 10, 2016
Merged

Conversation

jieter
Copy link
Member

@jieter jieter commented Jan 23, 2016

about first param to template.render:

/home/jieter/.virtualenvs/bootstrap/local/lib/python2.7/site-packages/bootstrap3/utils.py:142: RemovedInDjango110Warning: render() must be called with a dict, not a Context.
  return template.render(Context(context))

Let's see if this works better than my try in #292.

@jieter
Copy link
Member Author

jieter commented Feb 10, 2016

@dyve any reason not to merge this? would be nice to get rid of the warnings in test logs.

Hmm, I see I have some pieces commented out, let me fix that.

about first param to `template.render`:
```
/home/jieter/.virtualenvs/bootstrap/local/lib/python2.7/site-packages/bootstrap3/utils.py:142: RemovedInDjango110Warning: render() must be called with a dict, not a Context.
  return template.render(Context(context))
```
@dyve
Copy link
Member

dyve commented Feb 10, 2016

Just that I'm currently very busy. This looks OK to me, and if Travis agrees I'll pull it in.

dyve pushed a commit that referenced this pull request Feb 10, 2016
Fix Deprecation warning in Django 1.9
@dyve dyve merged commit 954fc40 into zostera:develop Feb 10, 2016
@jieter
Copy link
Member Author

jieter commented Feb 10, 2016

Thanks!

@jieter jieter deleted the patch-2 branch February 10, 2016 10:49
@dyve
Copy link
Member

dyve commented Feb 12, 2016

It looks like the fix has a bug, and that the Django 1.9 docs still advise to use Context. I don't understand the warning when the docs say:
https://docs.djangoproject.com/en/1.9/ref/templates/api/#django.template.Template

@jieter
Copy link
Member Author

jieter commented Feb 12, 2016

There seems to a difference between templates coming from get_template() and templates created by Template('foo {bar}')

https://docs.djangoproject.com/en/1.9/topics/templates/#django.template.backends.base.Template.render

"If context is provided, it must be a dict. If it isn’t provided, the engine will render the template with an empty context."

@dyve
Copy link
Member

dyve commented Feb 12, 2016

Let me see if I can work with that.

Op 12 feb. 2016, om 10:33 heeft Jan Pieter Waagmeester notifications@github.com het volgende geschreven:

There seems to a difference between templates coming from get_template() and templates created by `Template('foo {bar}')

https://docs.djangoproject.com/en/1.9/topics/templates/#django.template.backends.base.Template.render https://docs.djangoproject.com/en/1.9/topics/templates/#django.template.backends.base.Template.render
"If context is provided, it must be a dict. If it isn’t provided, the engine will render the template with an empty context."


Reply to this email directly or view it on GitHub #297 (comment).

@dyve
Copy link
Member

dyve commented Feb 12, 2016

Stumped

(InteractiveConsole)
>>> import django
>>> django.VERSION
(1, 9, 2, 'final', 0)
>>> from django.template import Template
>>> t = Template('foobar')
>>> t
<django.template.base.Template object at 0x10e345750>
>>> t.render()
Traceback (most recent call last):
  File "<console>", line 1, in <module>
TypeError: render() takes exactly 2 arguments (1 given)
>>> t.render({})
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/Users/dylan/.virtualenvs/django-bootstrap3/lib/python2.7/site-packages/django/template/base.py", line 201, in render
    context.render_context.push()
AttributeError: 'dict' object has no attribute 'render_context'
>>> 

@dyve
Copy link
Member

dyve commented Feb 12, 2016

>>> from django.template import Context
>>> t.render(Context({}))
u'foobar'

@dyve
Copy link
Member

dyve commented Feb 12, 2016

@jieter Are we missing something or did this change/warning somehow got bugged in 1.9.2?

@dyve
Copy link
Member

dyve commented Feb 12, 2016

Same in 1.9.1

@dyve dyve mentioned this pull request Feb 12, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants