Effective PyCharm (2021 edition) Transcripts
Chapter: Server-side Python web apps
Lecture: Selecting the template language
0:00 Remember that Flask could have Jinja or Mako and there's other frameworks like pyramid that
0:06 have Chameleon or even some extensions that I have written for,
0:10 say Fast API that allows you to use both Jinja and Chameleon with Flask API Those
0:16 are open source. If you care about them,
0:17 just check them out of my GitHub repo If I've got this dot html file,
0:22 remember straight away when I type something.
0:24 It it started doing all the cool stuff than it does for Jinja.
0:28 How does it know? How is it?
0:30 There's nothing about the extension here.
0:31 It's not like J2 or some odd things like that.
0:34 It's just html. How does it know which one of these we're going to use
0:38 if you created with Flask and you choose the option,
0:40 it sets that for the project but if you open an existing one,
0:44 it might not know if you want to change it,
0:47 how would it know? So let's go and open up the preferences real quick and
0:51 you come over here and type template languages to search for it.
0:54 Or you just go down to language.
0:55 Framework, template language and you can go down and add different file types and indicate
1:01 which ones those are being involved with for your templates and then here's what you do
1:05 Usually sometimes you'll find this set to be none and you'll get no auto complete
1:10 So if you get no auto complete in your html for the template side features
1:15 be a Chameleon or Jinja or whatever.
1:17 Go check this and realize that you might have to set it.
1:21 So we go over here and click Jinja
1:24 it will now know, but if I go over here and click Chameleon notice it will
1:29 be getting different stuff. So if I do that book no more help.
1:32 But if I had a div and chameleon we have this thing called the template attribute
1:36 language. So I'd say tal notice there's all the chameleon auto complete.
1:40 Why? Because I told PyCharm my html files are chameleon,
1:45 they're not Jinja because this is Flask but it's really important that if this is not
1:50 set you will get a much lower end experience.
1:53 Also note that this is a feature,
1:56 one of the first features were encountering that is a PyCharm professional feature when you
2:02 use the community one does a lot of cool things but it doesn't do the server
2:05 side web frameworks, you can create and run flask and other apps but you don't
2:10 get that integration, stay with the auto complete here and the navigation back and forth
2:16 like this and so on. So just make sure that if you're working with uh
2:22 template files and you haven't set that or some reason you didn't go through a path
2:26 that automatically selected it like a new Flask.
2:28 Project, choosing the template language that you go over,
2:33 do language frameworks, templates and you set it to what you want it to be