update pycharm instructions

This commit is contained in:
David Lord 2022-08-01 11:39:31 -07:00
parent 3e5ca2902e
commit 4c08e3a2ba
No known key found for this signature in database
GPG Key ID: 7A1C87E3F5BC42A8
3 changed files with 22 additions and 39 deletions

BIN
docs/_static/pycharm-run-config.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 76 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

View File

@ -552,53 +552,36 @@ script is available. Note that you don't need to set ``--app``. ::
PyCharm Integration PyCharm Integration
------------------- -------------------
PyCharm Professional provides a special Flask run configuration. For PyCharm Professional provides a special Flask run configuration to run the development
the Community Edition, we need to configure it to call the ``flask run`` server. For the Community Edition, and for other commands besides ``run``, you need to
CLI command with the correct environment variables. These instructions create a custom run configuration. These instructions should be similar for any other
should be similar for any other IDE you might want to use. IDE you use.
In PyCharm, with your project open, click on *Run* from the menu bar and In PyCharm, with your project open, click on *Run* from the menu bar and go to *Edit
go to *Edit Configurations*. You'll be greeted by a screen similar to Configurations*. You'll see a screen similar to this:
this:
.. image:: _static/pycharm-runconfig.png .. image:: _static/pycharm-run-config.png
:align: center :align: center
:class: screenshot :class: screenshot
:alt: Screenshot of PyCharms's run configuration settings. :alt: Screenshot of PyCharm run configuration.
There's quite a few options to change, but once we've done it for one Once you create a configuration for the ``flask run``, you can copy and change it to
command, we can easily copy the entire configuration and make a single call any other command.
tweak to give us access to other commands, including any custom ones you
may implement yourself.
Click the + (*Add New Configuration*) button and select *Python*. Give Click the *+ (Add New Configuration)* button and select *Python*. Give the configuration
the configuration a name such as "flask run". For the ``flask run`` a name such as "flask run".
command, check "Single instance only" since you can't run the server
more than once at the same time.
Select *Module name* from the dropdown (**A**) then input ``flask``. Click the *Script path* dropdown and change it to *Module name*, then input ``flask``.
The *Parameters* field (**B**) is set to the CLI command to execute The *Parameters* field is set to the CLI command to execute along with any arguments.
(with any arguments). In this example we use ``run``, which will run This example uses ``--app hello --debug run``, which will run the development server in
the development server. debug mode. ``--app hello`` should be the import or file with your Flask app.
You can skip this next step if you're using :ref:`dotenv`. We need to If you installed your project as a package in your virtualenv, you may uncheck the
add an environment variable (**C**) to identify our application. Click *PYTHONPATH* options. This will more accurately match how you deploy later.
on the browse button and add an entry with ``FLASK_APP`` on the left and
the Python import or file on the right (``hello`` for example). Add an
entry with ``FLASK_ENV`` and set it to ``development``.
Next we need to set the working directory (**D**) to be the folder where Click *OK* to save and close the configuration. Select the configuration in the main
our application resides. PyCharm window and click the play button next to it to run the server.
If you have installed your project as a package in your virtualenv, you Now that you have a configuration for ``flask run``, you can copy that configuration and
may untick the *PYTHONPATH* options (**E**). This will more accurately change the *Parameters* argument to run a different CLI command.
match how you deploy the app later.
Click *Apply* to save the configuration, or *OK* to save and close the
window. Select the configuration in the main PyCharm window and click
the play button next to it to run the server.
Now that we have a configuration which runs ``flask run`` from within
PyCharm, we can copy that configuration and alter the *Script* argument
to run a different CLI command, e.g. ``flask shell``.