PyCharm 2016.3 Help

Creating Templates

This feature is supported in 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".

  1. Place the caret at the unresolved reference to a template.
  2. Press Alt+Enter, or click the yellow light bulb to show the list of available intention actions.
  3. 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 file. You can specify the other directories in addition.

  4. 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 file.

  5. Click OK. The empty *.html file with the name in question is created in the specified location.

See Also

Last modified: 23 December 2016