On 13/03/2018 4:55 PM, Craig de Stigter wrote:
> Cheers Mike
>
> That deprecation notice says to me that Context itself is not
> deprecated, but the `current_app` argument is. I don't think that's a
> problem for us as I don't think we've ever used it.
>
> Perhaps I can clarify. As far as I can tell, according to the errors
> and deprecation warnings I'm receiving in Django 1.9:
>
> * `django.templates.base.Template.render()` requires a Context
> instance
> <
https://github.com/django/django/blob/stable/1.8.x/django/template/base.py#L206>,
> and does not accept a dict
> * `django.templates.backends.django.Template.render()` /requires a
> dict
> <
https://github.com/django/django/blob/stable/1.8.x/django/template/backends/django.py#L55-L70>,
> /and does not accept//a Context instance.
>
It is all news to me so I went looking. If you look at
django/template/__init__.py there seems to be a brief explanation. It
does start by saying the Django template namespace contains two
independent subsystems. One is for pluggable (and the Django template
language is pluggable) template backends. That's probably where the
Jinja template system plugs in. The other subsytem is the Django
template language itself.
I think the answer to your problem might be found in the imports in that
__init__.py
If you are *only* using the Django template system that enormous
codebase probably needs to be adjusted so it does all its
template-oriented imports from that file. In other words ...
from django.template import Template, Context, RequestContext and
whatever else you use.
Again, if you are only using Django templates you should be able to
safely drop imports from 'backend' in favour of the above 'from
django.template import ...'
Hope that works! Don't know of course but I reckon it would be worth a try.
Good luck
Mike
> <
https://docs.djangoproject.com/en/1.9/ref/templates/api/#rendering-a-context>
>
> Once you have a compiled |Template|
> <
https://docs.djangoproject.com/en/1.9/ref/templates/api/#django.template.Template>
> object, you can render a context with it. You can reuse the same
> template to render it several times with different contexts.
>
> /class /|Context|(/dict_=None/,
> /current_app=_current_app_undefined/)[source]
> <
https://docs.djangoproject.com/en/1.9/_modules/django/template/context/#Context>¶
> <
https://docs.djangoproject.com/en/1.9/ref/templates/api/#django.template.Context>
>
> This class lives at |django.template.Context|. The constructor
> takes two optional arguments:
>
> *
>
> A dictionary mapping variable names to variable values.
>
> *
>
> The name of the current application. This application name
> is used to help resolve namespaced URLs
> <
https://docs.djangoproject.com/en/1.9/topics/http/urls/#topics-http-reversing-url-namespaces>.
> If you’re not using namespaced URLs, you can ignore this
> argument.
>
> Deprecated since version 1.8: The |current_app| argument
> is deprecated. If you need it, you must now use a
> |RequestContext|
> <
https://docs.djangoproject.com/en/1.9/ref/templates/api/#django.template.RequestContext>
> instead of a |Context|
> <
https://docs.djangoproject.com/en/1.9/ref/templates/api/#django.template.Context>.
>> <mailto:
django-users...@googlegroups.com>.
>>
>> To post to this group, send email to
>>
django...@googlegroups.com <mailto:
django...@googlegroups.com>.
>> <
https://groups.google.com/d/msgid/django-users/aa356ec2-51d4-45d7-99a3-79ef14c775a5%40googlegroups.com?utm_medium=email&utm_source=footer>.