PyCharm Django project with Jinja2 templates - no named URL tags or navigation
Hi,
We migrated our Django project to use Jinja2 templates, but now don't get Django specific autocompletion (it worked before on Django's own template language). For example (the big one) when we create named url tags the route name isn't suggested.
{{ url('some_route') }}
These are the 2 key features which are no longer working. Normal Jinja2 tags such as `{% extends ... %}` etc work ok, so PyCharm certainly knows the files are Jinja2. It seems to be just the Django specific stuff which isn't working.
- https://www.jetbrains.com/help/pycharm/part-6-framework-specific-navigation.html#
Does anyone have any suggestions? I've trawled through settings and set everything in the way in which I think should work. I'm using PyCharm Professional.
Thanks for your help.
帖子评论已关闭。
Hi,
I think it should work, since we support Jinja2 templates for Django.
Could you provide a project example that reproduces the issue?
I have the same issue — {{ url('path') }} autocompletion and Go To feature doesn't work in PyCharm when switched from Django templates to Jinja2.
If it could help I can create an empty Django/Jinja2 project, but it's nothing special, just basic settings from djangoproject.com docs.
I think the problem is that PyCharm treats {{ url() }} as basic Jinja2 function and not as Django's {% url %} template tag.
Here is part of configuration:
Is there any news on that issue?
Jinja2 templates are first class citizen in Django now, but unfortunately we cant use {{ url('some_url') }} navigation with cmd+click in PyCharm as with Django templates {% url ‘some_url’ %} template tag.
On cmd+click the is a error: “Cannot find declaration to go to”
Hi Dmitry, this issue requires thorough investigation, please create an issue on YouTrack, attach all relevant information for quicker resolution, including a minimal project sample required to reproduce it.