Pycharm suddenly not detecting ANY Django tags in template
After a recent update Pycharm has started to throw warnings for any bit of Django template code. {% load %} tags, {% if %} or {% for %} loops, static files; anything.
Everything runs fine, I just have tons of warnings in my code that aren't accurate or helpful.
I have invalidated cache, triple-checked my INSTALLED_APPS and my settings.py in general. Again, it's working fine. Just throwing warnings that make no sense.
请先登录再写评论。
Hi,
Well, this is not normal. Please ensure that HTML is enabled as a file type for Django templates under **File | Settings/Preferences | Languages & Frameworks | Python Template Languages**
Does the issue reproduce if you create a new minimal project and test there?
I would also suggest to back up your settings (File > Export settins), then reset all settings to default by deleting the config directory (https://intellij-support.jetbrains.com/hc/en-us/articles/206544519) and check after that. This will show us if the issue was in your settings after all. Then you can import the settings back.
HTML is enabled as a file type for Python Template languages for Django. Will try wiping all settings.
Wiped all settings as described above and the problem persists.
Is my project structure setup correctly?
Everything looks correct on the screenshot. Does the issue reproduce every time in every project? If yes, please create a new project with some minimal code, ensure the issue is reproduced, and upload the zipped project to our FTP so we could try and reproduce inhouse (https://uploads.services.jetbrains.com/). After uploading, let me know the file name.
If the issue is only specific to your current project, let me know.
Created a new Django project with a similar basic format. The issue persists.
Filename is "pycharm_template_inspection_issues.zip"
I am encountering the exact same issue. My settings.py is correctly set up, project structure is as suggested, Django support is obviously enabled and points to the correct folders and files, template language is django and html files are included.
Strangely, autocompletion/suggestions for paths pointing from templates to other templates or static files work fine. The extends, include and the block tags are apparently recognized normally by PyCharm, but all other tags so far (i.e. load, if, for, static, url) are highlighted as "unresolved tag".
Currently trying out the professional version:
Django support was a major argument for getting the pro version, so it would be nice if this was fixed. Any help is greatly appreciated.
@iamjonmiller
Thanks for the project. Unfortunately I can't reproduce the issue, the tags are resolved correctly for me.
Please provide log files (can be located according to https://intellij-support.jetbrains.com/hc/en-us/articles/207241085-Locating-IDE-log-files), your Python and Django versions.
Just spent my morning resetting my environment twice. Despite uninstalling Pycharm, removing all associated caches, registry keys, settings, temp data, and even deleting the .idea folder in my project, and then doing a fresh install with no imported settings; the issue remains. As soon as Pycharm loads up my project and inspects it, it is riddled with inaccurate error messages.
I uploaded my logs to the link you provided earlier. Filename is "jmiller-pycharm-logs-20190508-114029.zip"
What @df describes is exactly my issue.
Could you please provide the
output for the interpreter used by the project? The problem is reproducible for me while no interpreter is selected, but as soon as I point the project to the Python with Django installed it starts to resolve tags correctly.
@Pavel Not sure why that would be helpful for finding the problem, but here you go:
Suffice it to say, I have of course pointed Pycharm to the correct interpreter, that being the virtual environment created using pipenv. And yes, Django is installed in that virtual environment.
Here is a screenshot:
By the way, the recent update to PyCharm did not fix the problem. Please let me know, if I should wait with buying a license until you fixed the problem since this is an important issue for me.
Could you please remove django-stubs? It seems to cause the problem.
Thank you, this actually solved the issue (for me)! Intresting, why that is though. Since I currently don't need these stubs packages, this solution is fine for the moment.
(It may be worth noting for someone with the same issue that to remove django-stubs, djangorestframework-stubs had to be removed as well due to the latter's dependency on the former.)
Thank you Pavel! I really appreciate you chasing this down. Everything is working again!
I have been seeing exactly the same problem for the last 3 days and have gone through reinstallation and all manner of attempts to try and track it down.I don't know when it started to appear - possibly when I moved from Python 3.6 to 3.7 or maybe when upgrading to PyCharm 2019.1.3.
Along the way I noticed that if I changed the template language to Jinja2, the errors disappeared, but was not 100% happy with that as a solution.
Removing django-stubs and djangorestframework-stubs fixed it for me too!
I am experiencing this as well and I have tried all the settings things as described. Do you see anything that would break this functionality in this pip freeze?
(virtualenv) jebsky@theSeed ~/web/yogijeffrey $ pip freeze
beautifulsoup4==4.7.1
bleach==3.1.0
braintree==3.40.0
certifi==2018.1.18
cffi==1.12.1
chardet==3.0.4
cssutils==1.0.2
Django==1.11.7
django-appconf==1.0.2
django-compressor==2.2
django-inlinecss==0.2.0
django-naomi==0.8
eyeD3==0.8.9
future==0.17.1
html5lib==1.0.1
idna==2.6
itsdangerous==1.1.0
Jinja2==2.10
MarkupSafe==1.1.0
olefile==0.44
Pillow==4.3.0
pycparser==2.19
pydub==0.23.1
pynliner==0.8.0
python-magic==0.4.15
pytz==2017.3
rcssmin==1.0.6
requests==2.18.4
rjsmin==1.0.12
six==1.12.0
soupsieve==1.9.1
urllib3==1.22
webencodings==0.5.1
Werkzeug==0.14.1
Hi Jeb16, could you please create a ticket in PyCharm's bug tracker and provide more details about where and which exact warnings are shown?
I had the exact same issue, and it solved it removing djangorestframework-stubs & django-stubs as @Pavel mentioned.
Is there any way to fix the bugs with these packages installed?
Hi,
I have latest Pycharm 2019.2 professional version. Ubuntu 18 LTS, python 3.7
I dont have djangorestframework-stubs & django-stubs in my virtual env or global system. I still have the same issue.
Some one on stackoverflow suggested this - https://stackoverflow.com/a/22892150/3842788 but that generates error when deploying on google app engine.
Pycharm has cost me a lot of time for configuration and bug fixes.
I can confirm that removing django-stubs has fixed the issue.
Is this a problem with Pycharm or django-stubs is missing stubs?
Try PyCharm 2019.3 EAP version. With PY-36265 in place the problem should be obsolete.
In my case, it was "Vue.js" plugin that was giving me trouble.
The solution was to add "Vue.js template" in Settings -> Languages & Frameworks -> Template Languages -> Template File Types.
I am also having the problem with the PyCharm showing {{tags}}
PyCharm 2020.2.3 (Community Edition)
Build #PC-202.7660.27, built on October 6, 2020
Runtime version: 1.8.0_261-b12
VM: Java HotSpot(TM) Server VM by Oracle Corporation
Linux 4.15.0-121-generic
GC: ParNew, ConcurrentMarkSweep
Memory: 2035M (showing but I have 5GB installed on my system...? )
Cores: 2
Current Desktop: Linux Ubuntu 18.04 LTS for i386
Python 3.6.5
Django == 3.0.1
Running on VirtualEnv
So this is base.html in the TEMPLATES folder (configured the settings as should)
and now from base.html everyone inherits and that's OK, but
This is about.html:
It doesn't show the context tags from views.py:
It was working...In another project but as soon as I've updated it is like this...
Here's the modules installed:
I have added these "wheezy" things and djangorestframework, django-rest-framework, and HTSQL, HTSQL_DJANGO to see if it will help - nope...
Please help!!!!
I cannot finish learning Python and Django... :(
Milanovicful
Hi,
You mentioned you're using Community version, which doesn't support Django, so tags won't be resolved.
Do you see any error?
I have to say that, that is simply not true. In another tutorial just a day before, I was able to use tags. What happened... Does it have to do with update?
You can use tags, but they won't be resolved by code insight, and won't be highlighted.
Could you provide more information about your issue? Screenshot would help.
I know that Pro version offers Special Support, but when I was following that tutorial {{ }} tags were appearing. Now when I switched to some other which works on django2.x instead of 3.x they all the sudden do not appear. I dont think I have screenshots but I will check, as I am the phone right now, tomorrow by UTC+1 (Belgrade, Europe) time. I will follow again the tutorial where they show up the {{tag}} which should displaye context of def...Question (request) :
'tag': 'sometext'
Return render(...'page.html',context...)
And Base. Html for instance{% includes Base.html %} is working but when I try to get context at {{ item from the context list1}}, {{... item from the context list 2}} tags it display only the "," sign...
While following previous tutorial (this one is trydjango with installed 3.0.1 django and Python 3.6.5 and doesnt work, while I was following tutorial from Mr. Parwitz I did fine..
😢😢😪
I just solved the problem,
When loaders are set, APP_DIRS needs to be set to False,
But Setting APP_DIRS to False causes PyCharm to fail to resolve the tag,
Comment out loads,and APP_DIRS set True, Problem solved!
This problem still exists on PyCharm 2022.2.1. As a paying subscriber for over 3 years, silly unresolved problems like these have me considering VS Code more and more. Removing django-stubs package fixes. Why can't JetBrains handle this? Annoying.
I have the same problem with 2022.2.2 - suddenly stopped parsing django templates correctly. Funnily, the problem is visible in django's own files (in my django env's `contrib/admin/templates/admin/edit_inline/tabular.html`), as where my own projects' .html files are unaffected.