PyCharm 2024.2 Help

Django support

Enable the Django plugin

This functionality relies on the Django plugin, which is bundled and enabled in PyCharm by default. If the relevant features are not available, make sure that you did not disable the plugin.

  1. Press Ctrl+Alt+S to open settings and then select Plugins.

  2. Open the Installed tab, find the Django plugin, and select the checkbox next to the plugin name.

Prerequisite

Django framework and the corresponding Python interpreter are properly installed on your machine.

Supported versions of Django and Python

PyCharm supports the latest Django versions. The corresponding Python versions depend on Django. See What Python version can I use with Django?

Django support

Django support in PyCharm includes:

Enabling or disabling Django support

Django support for a Python project can be turned on or off by selecting/clearing the checkbox Enable Django support in the Django page.

To enable Django support, follow these steps:

  1. Open the project Settings dialog (Ctrl+Alt+S) and navigate to the Languages & Frameworks | Django page.

  2. Make sure that the checkbox Enable Django support is selected. You can also use the fields below to configure the required settings:

    Item

    Description

    Enable Django support

    The default state of this checkbox depends on the project type. For the empty projects, Django support is disabled. For the Django projects it is enabled by default; you can clear this checkbox if required. In this case, the other fields become unavailable.

    Django project root

    By default, this field shows the directory that contains all project files. If required, you can specify a different location.

    Django project root field

    Settings

    Click the browse button to select the desired settings file.

    Use one of the following approaches:

    • This can be any file with the name matching *settings*.py, located under the Django project root.

    • Point to any Python package and store settings in __init__.py.

      This latter approach is useful when you want to split settings to several modules and import them.

    By default, PyCharm shows the settings.py file, located in the Python package directory of your Django project.

    Do not use Django test runner

    By default, this checkbox is not selected. You can select it if you want to use any of the alternative test runners specified in the PyCharm Integrated Tools dialog window (File | Settings | Tools | Python Integrated Tools for Windows and Linux and PyCharm | Settings | Tools | Python Integrated Tools for macOS).

    Manage.py tasks

    Manage script

    Specify here the desired manage.py file for the current project.

    By default, PyCharm shows the manage.py file, located under the Django project root. Click the Browse button to select the desired manage file from the file system.

    Environment variables

    Specify here the environment variables to be passed to the script. Click to open the Environmental Variables window. Press to add a new variable and enter its name and value in the corresponding fields.

    Environment variables field

    Folder pattern to track file

    Specify here folder names separated with colons. If needed, you can use Glob-style wildcards. Django only pulls and adds to VCS files matched by this pattern.

    Folder pattern to track file field
  3. Apply changes (if any) and close the dialog.

Last modified: 18 September 2024