Setting up Django to run in PyCharm can be useful as it will enable you to run your project from directly within the IDE. To do this, open PyCharm and go to File > Settings > Project > Python Interpreter.
From here you should see a window like this, your Python Interpreter will likely be empty though.
So, click on the ‘Add Interpreter’ dropdown and ‘Add Local Interpreter’.
In the subsequent window, enter the path to where you would like your Virtual Environment to exist and then click ‘OK’.
Next, click on the dropdown menu towards the right of the PyCharm window & select ‘Edit Configurations’.
From this window, you can enter the configuration of your server. You can enter:
- Where your manage.py script resides
- Where your application files are
- The command to run (runserver).
Finally, open your Requirements.txt and press the button in the top right to install requirements. This should configure the environment exactly as you require.
Now you can run your server!
This should provide a message like the below. Upon navigating to the provided localhost URL, you should see your app.