Pycharm not recognizing django template tags
I had to reinstall my mac osx and on installed a fresh copy of pycharm. I cloned a git django project and I loaded the project using open directory and it didn't recognize it. Then I ticked enable django support and everything works, I can run and stuff, except that the IDE is not recognizing my template tags such as {% for ... %} and it is not creating the closing brackets automatically. Further, the syntax highlight for the template tags are not working as well.
Any solutions?
请先登录再写评论。
Please make sure that the Django template format is selected under Settings | Template Languages.
I'm having the same problem and my Template Language is set to Django.
Ralph,
Could you please attach a screenshot demonstrating the problem?
Attached screen shot show template settings and template file open in editor. Highlighting not being applied.
Attachment(s):
no template highlighting.tiff
I'm sure it's got something to do with the .idea directory.
I tried everything, even opening my other django project that has everything working and setting the exact same settings. It still doesn't work. So in the end I deleted the default .idea directory and copied over the .idea from the django project that was working. I opened up the project, a few errors popped up and after that everything was working fine.
Please map the .djt extension to the HTML file type in Settings | FIle Types.
Problem solved. Thanks!
*.djt
I have the exact same problem. My Template Language is set to Django and I've mapped the *.djt extensions to the HTML file type in Settings | File Types. Still, no template tags are being highlighted. What's more, line comment or code formatting are not working in my HTML files.
@Martyszek
Please provide screenshots to demonstrate the issue and **idea.log** file, which you can find using **Help > Show log in...** action.
Ensure that you have HTML Tools plugin enabled.
Hi i have the same problem, i've checked that html plugin is enabled and in the settings there is an extension *.djt, but the problem isn't solved. I attached a screenshot.
Template tags are not recognized, please notice also the changed icon of the .html file. I've done all of the above, nothing seemed to be the case.
Do you have Vue.js plugin installed?
There is a known issue with it https://youtrack.jetbrains.com/issue/PY-41619
If Vue.js plugin installed
Add Vue.js template in Settings | Languages & Frameworks | Template Languages | Template File Types it's fix Django template support
axel thanks a lot! it was bugging me for a long time
axel you saved my day and my year !
Custom Template Tags and Inheritage| Loops and Ifs/ Else
My issue was the same, just I wasn't careful when I was setting up the settings.py in templates the DIR:[ ] has to show on 'templates' (folder inside the app), or the path of it 'absolute path', as well as I haven't pay the attention on context rendering and hmtl tags inside of base.html file.
So finally I got the {{list}} and {{my_num}} working by configuring it like this:
And
So basic example that PRACTICE and PAYING ATTENTION ON THE SMALLEST DETAILS CAN occur in issue while rendering your pages/templates and template custom tags/tags.
Thank you all, and PyCharm Community and Intellij-support/ jetbrains.com @Andrey Leisler @..., @... Sergey Karpov and @...(for pulling out this 'charming' topic) it's been a 100... :)
One Feature Request (as I worked as DevOps in one huge reputable enterprise company):
i could not find the template languages settings
Takizee53
It looks like you are using PyCharm Community while Django support is available only in PyCharm Professional.
I had the same issue and found that I needed to update the settings:
In Pycharm choose File -> Languages & Frameworks -> Django -> Settings:
Once I pointed it to the projects app/settings.py file it started to work again.