Creating Templates
This feature is supported in the Professional edition only.
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>:
Create Template dialog box appears, showing the read-only template name (Template path field), and a drop-down list of possible template locations (Templates root field).
Note that PyCharm automatically discovers the directories specified in the
TEMPLATE_DIRS
orTEMPLATE_LOADERS
fields of thesettings.py
file. 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_DIRS
orTEMPLATE_LOADERS
variables of thesettings.py
file. - Click OK. The empty
*.html
file with the name in question is created in the specified location.