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.

21 comments
Comment actions Permalink

Could you please remove django-stubs? It seems to cause the problem.

3
Comment actions Permalink

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.

1
Comment actions Permalink

HTML is enabled as a file type for Python Template languages for Django. Will try wiping all settings.

 

1
Comment actions Permalink

Wiped all settings as described above and the problem persists.

Is my project structure setup correctly?

1
Comment actions Permalink

Created a new Django project with a similar basic format. The issue persists.

 

Filename is "pycharm_template_inspection_issues.zip"

1
Comment actions Permalink

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:

PyCharm 2019.1.1 (Professional Edition)
Build #PY-191.6605.12, built on April 3, 2019
Licensed to PyCharm Evaluator
Expiration date: May 27, 2019
JRE: 11.0.2+9-b159.34 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Windows 10 10.0

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.

1
Comment actions Permalink

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"

1
Comment actions Permalink

What @df describes is exactly my issue.

1
Comment actions Permalink

@Pavel Not sure why that would be helpful for finding the problem, but here you go:

beautifulsoup4==4.7.1                                                                                                   
certifi==2019.3.9                                                                                                       
chardet==3.0.4                                                                                                          
colorama==0.4.1                                                                                                         
dataclasses==0.6                                                                                                        
Django==2.2.1                                                                                                           
django-crispy-forms==1.7.2                                                                                              
django-filter==2.1.0                                                                                                    
django-stubs==0.12.1                                                                                                    
djangorestframework==3.9.3                                                                                              
djangorestframework-stubs==0.4.2                                                                                        
httpie==1.0.2                                                                                                           
idna==2.8                                                                                                               
multiprocessing-logging==0.2.6                                                                                          
mypy==0.701                                                                                                             
mypy-extensions==0.4.1                                                                                                  
mysql-connector-python==8.0.16                                                                                          
mysqlclient==1.4.0                                                                                                      
protobuf==3.7.1                                                                                                         
Pygments==2.3.1                                                                                                         
pytz==2019.1                                                                                                            
PyYAML==5.1                                                                                                             
requests==2.21.0                                                                                                        
selenium==3.141.0                                                                                                       
six==1.12.0                                                                                                             
soupsieve==1.9.1                                                                                                        
sqlparse==0.3.0                                                                                                         
typed-ast==1.3.5                                                                                                        
typing-extensions==3.7.2                                                                                                
urllib3==1.24.3                                                                                                         

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.

1
Comment actions Permalink

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.

0
Comment actions Permalink

@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.

0
Comment actions Permalink

Could you please provide the

pip freeze

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.

0
Comment actions Permalink

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.)

0
Comment actions Permalink

Thank you Pavel! I really appreciate you chasing this down. Everything is working again!

0
Comment actions Permalink

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!

 

 

0
Comment actions Permalink

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

0
Comment actions Permalink

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?

0
Comment actions Permalink

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?

0
Comment actions Permalink

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.

0
Comment actions Permalink

I can confirm that removing django-stubs has fixed the issue.

Is this a problem with Pycharm or django-stubs is missing stubs?

0
Comment actions Permalink

Try PyCharm 2019.3 EAP version. With PY-36265 in place the problem should be obsolete.

0

Please sign in to leave a comment.