The storage for templates can be specified on creating a Django project or a Google App Engine project ; at a later time, one can configure the directories for templates, using the Python Template Languages page of the Settings/Preferences dialog.
To create a template for a view
Suppose you reference a template file that doesn't yet exist. PyCharm marks such a reference as unresolved, and provides an intention action to create a template file "from usage".
- Place the caret at the unresolved reference to a template.
- Press Alt+Enter, or click the yellow light bulb to show the list of available intention actions.
- From the suggestion list, choose action Create template <name>:
Note that PyCharm automatically discovers the directories specified in the
TEMPLATE_LOADERSfields of the
settings.pyfile. You can specify the other directories in addition.
- In the Create Template dialog box, select the template directory, where the new template will be created.
The Template root field provides a list of possible locations for the new template. This list includes the template directories specified in the Python Template Languages page of the Settings dialog, plus the directories, which are automatically detected in the
TEMPLATE_LOADERSvariables of the
- Click OK. The empty
*.htmlfile with the name in question is created in the specified location.