Does PyCharm support Jinja2? - python

A bottle project of mine uses Jinja2. PyCharm does not automatically recognize it and shows such lines as errors. Is there a way to make Jinja2 work?

In the pro edition, these template languages:
Jinja2
Django
Mako
are supported. You can configure the template language in the project's settings:
The community edition may lack certain template languages.

I think it's worth to mention that PyCharm Community edition does not support Jinja2, Mako and Django. It's available only in PyCharm Professional.
See comparison of the two.

Yes pro edition from pycharm does support Jinja2 to enable it go here
From File open Settings and search for python template under Languages & Frameworks Select Python Template Languages from there Click HTML And Select Jinja2 as Template Language.
please see the image for better understanding.

If you are using .jinja extension instead of .jinja2, it won't work, templates are not highlighted.
You have to add the file extension to the filetypes section.
Preferences > General > Filetypes
Scroll to Jinja 2 Template
Register new pattern by clicking +, add *.jinja

In community edition, the python template option is not available, so you can simply click on python packages next to the terminal present on the bottom. This will also add Jinja2

Related

How to use sublime 3 jinja2 highlighter

I have a problem with jinja2 highlighter in sublime 3.All the files associated with .html
extensions don't recognize jinja templates blocks..I searched the web but the only solution I found is to make a .jinja.html custom extension..anyone got any idea how to solve this?..This is the plugin I installed https://packagecontrol.io/packages/Jinja2
You need to add .j2 to your file extension:
mysupertemplate.html.j2
Have a look at the syntax file (under fileTypes)

How to use markdown for python with PyCharm?

I'm new to python and I've been using PyCharm (4.5 Community Edition) as my IDE on a Mac OS X v11 system. I've installed the markdown plug-in and enabled the package in pycharm (Actions>Plugins>Markdown is checked, program restart complete).
When I create a new markdown file (test.md or test.markdown) I can see the preview tab. But I don't see anything in the preview tab. Also, I can't "run / execute" this file. So seeing a preview would be nice. Ideally, I would like to be able to execute python chunks with markdown comments in-between and see the output rendered in a local browser if this at all is possible.
This was really easy in the Rstudio IDE and a super powerful way to communicate findings.
Any suggestions? Help much appreciated.
Uninstall Markdown Support (by Jetbrains) (has no side preview)
Install Markdown Navigator 2.0 (by Vladimir Schneider) (has side-preview)
https://github.com/vsch/idea-multimarkdown
This should give you a per-compiled side view of you .md file.
I'm on the same boat. Making transition from RStudio to PyCharm. You can install markdown plugins directly within the PyCharm settings. Within Pycharm I searched and downloaded "Markdown support". Once you're editing the Markdown file, you should have a "view" to see the markdown in raw or rendered format and even some formatting buttons like in a normal Text Editor.
I think you need to follow these tag instructions to have the HTML render correctly.
You should also take a look at IntelliLang for language injections, which I think are equivalent to R "chunks".
The default setting for Markdown files - with a fresh copy of Pycharm - is preview mode only:
Just change it to side-by-side mode:
No requirement to install additional plug-ins.
https://www.jetbrains.com/help/idea/markdown.html#preview
Currently PyCharm has two plugin options for .md format: PlantUML and Mermaid.
According to the official docs, in order to enable md support:
Go to File -> Settings -> Languages & Frameworks -> Markdown.
(in recent versions: Pycharm -> Preferences -> Languages & Frameworks -> Markdown)
Install either of these plugins.
Close and Reopen PyCharm (it did not work instantly for me)
In order to see a file preview move a mouse to the upper right corner and select this option.
I've found that a much better way to achieve what I was trying to accomplish when I asked this question is to utilize jupyter notebook (jupyter.org/).

How to provide Python syntax coloring inside Webstorm?

I have a Python project, and I use WebStorm as my Editor. The problem is that Python's syntax doesn't get colored.
How can I display Python pages with a nice syntax? I am not searching more than than. I'm not going to develop pages in Python, but I do want them to get displayed nicely in Webstorm.
Your ONLY option in WebStorm is to use TextMate bundles support plugin with Python bundle -- it will provide syntax highlighting (no completion or syntax checking etc).
This official article (with pictures) is for PhpStorm, but it should work the same for WebStorm as well: http://confluence.jetbrains.com/display/PhpStorm/TextMate+Bundles+in+PhpStorm
There are several TextMate bundles available for Python: https://github.com/textmate?utf8=%E2%9C%93&q=python
Alternative solution: migrate to PyCharm Pro -- it does all what WebStorm does + Python.
UPDATE: 2019-06-18
2019.2 version will come bundled with syntax highlighting for about 20 languages (all done via the aforementioned TextMate bundles plugin).
https://blog.jetbrains.com/webstorm/2019/05/webstorm-2019-2-eap/
In WebStorm 2019.2, we’re adding syntax highlighting for over 20 different programming languages, including PHP, Python, Ruby, and Java. It just works – no additional configuration needed.
With this change we want to improve the experience of our users who occasionally have to look through some code written in different languages that are not supported in WebStorm. But WebStorm is still primarily an IDE for JavaScript and TypeScript developers, so we don’t plan to extend the support for these other languages beyond syntax highlighting.
Syntax highlighting for these languages is built using TextMate grammars, and WebStorm bundles a collection of grammar file for different languages. Currently they are shipped as part of the TextMate Bundles plugin (so you can see a full list of supported languages under Preferences | Editor | TextMate Bundles), but they are going to be moved to the IntelliJ Platform soon.
You can use the Perl syntax which is very similar to Python.
Go to Preferences => File Types
Search for Perl
Add *.py under Registered Patterns
Another option is to use PyCharm, the community version is free.
Python might be missing in Preferences -> Editor -> File Types. After adding the Python, make sure to add a *.py registered pattern.

Pycharm resolving references in Django templates

Is it possible for PyCharm to resolve references in Django templates? i.e., some code completion support, and when Ctrl + click on a template variable, we should go to the relevant python object.
The Jetbrains website boasts some impressive magic about Django templates:
Code completion works for Django tags, filters, template variables
and parameters passed from view methods.
The review on Dr Dobbs confirms this functionality. But I can't seem to get it to work:
I have setup the correct interpreter from my virtualenv, enabled Django Support in the settings and configured the templates directories, even invalidated and rebuilt the caches.
I'm on PyCharm v3.0.2.
In order to get this kind of functionality, you will need to see an icon on your views.py file, of the corresponding html file:
Using 3.0.2 here:
Either way, I will need to have a look at your directory and views.py file before I can tell you whats wrong with your source.
I had the same problem and I solved it by figuring out that my settings.py file was not configured in File > Settings > Languages & Frameworks > Django. Once I did that all intellisense clicked into place.
I've heard that this is a Pro-only feature but I cannot confirm that as I'm using a Pro license.

Django development IDE [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 9 years ago.
Improve this question
I have done a little Django development, but it has all been in a text editor. I was curious what more advanced development tools others are using in their Django development.
I am used to using Visual Studio for development and really like the IntelliSense, code completion, and file organization it provides and would like to find something (or a combination of tools) that would provide some of this in the Django/Python environment.
There is PyCharm from JetBrains which supports Django and Google Apps. It looks promising.
Note: You need to buy a license for the Professional version if you want Django support. The Community version desn't support Django.
I use Eclipse and a plain vanilla PyDev. There isn't any specific Django functionality. The best I came up with was setting up a run profile to run the development web server.
If you add the web tools project (WTP), you'll get syntax highlighting in your templates, but nothing that relates to the specific template language. PyDev is a decent plugin, and if you are already familiar with Eclipse and use it for other projects it is a good way to go.
I recall NetBeans starting to get Python support, but I have no idea where that is right now. Lots of people rave about NetBeans 6, but in the Java world Eclipse still reigns as the king of the OSS IDEs.
Update: LiClipse is also fantastic for Django.
Install it, use this method to get the icon into Ubuntu's menu. Start LiClipse and in File > New > Project ..., select PyDev and PyDev Django project. You may have to set up your Python interpreter etc, but that you'll be able to figure out on your own. Once the Django project is created, you can right click on the project and the menu will have a "Django" option, which allows various things like creating a Django app or running migrations etc. LiClipse is good because it consumes far lesser memory than PyCharm and supports refactoring and autocomplete reasonably well.
I use Vim:
http://github.com/skyl/vim-config-python-ide
[UPDATE]
Sublime Text 2 is pretty awesome. It supports a lot of Vim commands if you want them: Vintage Mode
It has a nice package manager: http://wbond.net/sublime_packages/package_control
I use these packages so far:
Djaneiro
SetDjangoSyntax
CoffeeScript
SublimeLinter
Theme - Soda
SideBarEnhancements
I still love Vim but ... did I mention that Sublime Text plugins are written in Python?
I use Komodo Edit. Check out the Open Komodo Edit.
Sublime
I am beginning to enjoy working with Aptana Studios + PyDev (and other) plugins for all sorts of web application development. As you can tell, it is built on top of the powerful Eclipse, but is tailor-designed to focus on web application development.
I use Kate (KDE Advanced Text Editor) for most of my development, including Django. It has both a Python and Django Templates syntax higlighting. I switch to Quanta+ when a significant part of the project involves HTML.
Since it uses Kate's KPart, it's just as good for editing the Python parts, and for the HTML templates i have the whole Quanta+ tools, while still highligting Django-specific tags.
Update 2013: Unfortunately, Quanta+ has been dead for years now, and there's no hope that it will ever be resurrected. Also, there's no other usable HTML editor out there, so it's Kate all the time now.
NetBeans for Python is my current favorite (lighter and so much easier to install than Eclipse I found). Supports simple refactoring, autocompletion, errors/warnings...
Eclipse Aptana PyDev probably one of the most complete free IDE nowadays (haven't tested a lot)
Wingware Python IDE a commercial IDE, which has some Django-specific project setup features the ability to debug Django template files.
IntelliJ IDEA Ultimate Edition another commercial IDE which has also a plugin for Python that is under heavy development. I saw some demo which look very promising on the auto-completion (for templates and Python).
Vim which I still use a small touch-fix application. See also: Extra tweaks for Django.
PyCharm. It is best the IDE for Python,Django, and web development I've tried so far. It is totally worth the money.
You guys should checkout PyCharm! It is the first decent Django IDE.
Eclipse has the PyDev plugin for python development. Unfortunately, I'm not sure how well it integrates with Django.
As far as I know there is not "an IDE" for Django, but there are some IDEs that support Django right out of the box, specifically the Django syntax for templates.
The name is Komodo, and it has a lot of features, but it's not cheap. If you are not worried about source control or debugging then there is a free version called Komodo Edit.
There is an actual Python extension for Visual Studio: http://pytools.codeplex.com/. It's absolutely fantastic. It feels the same as if I were coding in any native Visual Studio language. The extension is even compatabile with Django. And best of all: it's totally free. Even for Visual Studio, it only requires the Visual Studio Shell to work, which is completely free.
Now you can also use Visual Studio 2010. Here's how:
Download and install Python Tools for Visual Studio.
Create a new project from existing code (menu File → New → Project From Existing Code...)
Specify your Django project folder and use the defaults.
Right-click on manage.py and choose Set as Startup File.
In your project properties Debug tab, add "runserver" in Script Arguments.
You can set break points, and attach to the Python process for debugging. If you want to debug without having to "attach to process," use "runserver --noreload" in your script arguments. However, the "--noreload" means you'll have to stop and restart the Django development web server manually (to recognize your code changes).
This is a nice setup if you already use Visual Studio.
Python Tools has been updated. It has built in support for Django now.
PyCharm, definitely. I tried them all (almost), but PyCharm is the one I found most useful for any heavy development.
For simple, one time, scripts I use whatever comes to mind (TextMate, Vim, Emacs, TextWrangler, etc., you name it).
I have used Eclipse with PyDev and PyCharm. PyCharm is definitely the best IDE for Django/Python I have tried. It does proper template highlighting and auto-completion for all objects. It also does cross-file referencing.
It's quite expensive, but definitely the best Django IDE I have tried. You can try a 30 day evaluation at http://www.jetbrains.com/pycharm/download/.
I've also had good results with Eclipse and Pydev. Although I still require a shell opened to the project directory to run manage.py commands. I've also been using it with the Bazaar plugin for revision control and syncing code with the server.
I really like E Text Editor as it's pretty much a "port" of TextMate to Windows. Obviously Django being based on Python, the support for auto-completion is limited (there's nothing like intellisense that would require a dedicated IDE with knowledge of the intricacies of each library), but the use of snippets and "word-completion" helps a lot. Also, it has support for both Django Python files and the template files, and CSS, HTML, etc.
I've been using E Text Editor for a long time now, and I can tell you that it beats both PyDev and Komodo Edit hands down when it comes to working with Django. For other kinds of projects, PyDev and Komodo might be more adequate though.
I use Kate as well. Kate's simplicity is its biggest feature. It doesn't get in your way. (This is of course highly subjective opinion.)
Kate includes a Python code browser plugin. But it isn't useful IMO. No automatic updates when you change the code/view. Also when you update, the whole tree is collapsed, and you have to expand it again yourself. Too many clicks.
Instead, I use the Source Browser plugin that comes with Pâté. It does cause Kate to freeze temporarily sometimes, but no crashes or anything of that sort so far.
Shameless blog plug: more on using Django with Kate (Pâté)
Well, I've been using my own one. Recently they released an alpha version. Here it is at pfaide.com/.
If you like Vim as an editor, here are some suggestions on how to tune it (up to the point of a full fledged IDE) for Django development: http://code.djangoproject.com/wiki/UsingVimWithDjango.
Editra supports Django Template Language syntax highlighting. You can configure it either as a better Notepad or a basic IDE.
I made a blog post about NetBeans' new and upcoming support for Django. When paired with its already fantastic Python, JavaScript, HTML and CSS support, it's a strong candidate in my mind!
TextMate with the Django and django-html bundles installed gives you syntax highlighting and great extensibility. It is lightweight and fun to use.
Here is a link to a code completion project for TextMate with Python (which I haven't used myself). As for "intellisense" (which I understand to be inline-doc reference), TextMate has that too.
The Wingware editor from http://www.wingware.com is Python-specific with very good auto-completion for Python/Django/Zope, etc.
It has a built in Python shell to run snippets (or select and run) and support for Mercurial/Git, etc. and a built-in unittest/nose/doctest test runner. It's commercial though, but as it is written in Python, it's cross platform.
I bought it a while ago, and thought it looked dorky, but I've tried them all and keep coming back. Caveat that I am a Windows guy with no Emacs or Vim skills, so leveraging that was not an option. And the Mac version requires X Window and seems to be more glitchy.
Geany
It is GTK2 based, fast, lightweight, available for Linux and Windows.
Ninja-IDE.
Check this: Ninja-IDE Django Plugin
Ulipad is a good one.
http://code.google.com/p/ulipad/
I have consistently used Vim or Kate, but I would prefer a full-blown IDE. Given it is not as heavy as Visual Studio.
I like Eclipse + PyDev and/or eric, myself. The new version of PyDev has some pretty awesome code completion support.
Since I only use Eclipse for PyDev, I use a slim install of just the Platform Runtime Binary + PyDev + Subclipse.

Categories

Resources