Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding Flask support to an existing Pycharm project

I'm working on a small project where it would be helpful to display trivial web pages. It's being developed in PyCharm, the pro edition.

This is an existing project, so it wasn't created as a Flask app to begin with.

I've added Flask to my requirements.txt and ensured that its installed. However, I don't get autocompletion of any Jinja templates - essentially, the HTML file I created is treated like dumb HTML.

How do I get PyCharm to recognize that I'm using Flask and to act accordingly?

IDE Screenshot

like image 901
Mikey T.K. Avatar asked Jan 24 '16 15:01

Mikey T.K.


1 Answers

You have to tell PyCharm which folders contain your templates.

  1. Go to Settings/Project: NAME/Project Structure
  2. Click on the folder containing your templates and click the purple Templates button.

It will probably warn you that no template language is specified. If that is the case

  1. go to Settings/Language & Frameworks/Python Template Languages
  2. In the combobox Template Language: select your template language (jinja?)
  3. Under Template file types select the file type (probably HTML)
like image 172
Wombatz Avatar answered Nov 03 '22 04:11

Wombatz