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+EnterAlt+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 or TEMPLATE_LOADERS fields of the settings.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 or TEMPLATE_LOADERS variables of the settings.py file.
- Click OK. The empty *.html file with the name in question is created in the specified location.