Anuj TBE
Anuj TBE

Reputation: 9790

change django application directory in PyCharm

I have set up a Django project in PyCharm using pipenv.

I have used pipenv to create the virtual environment in my project directory. Within the virtual environment directory, I have created src directory to place my Django project.

The directory structure is like

/ Project Directory
|- src
   |- django_app
   |- other_app
   |- manage.py
   |- db.sqlite3
|- Pipfile
|- Pipfile.lock

In PyCharm IDE, I have opened the Project Directory as a project.

When I use Alt+Enter to auto import modules from other apps. The import line is prefixed with src. like

from src.other_app.models import ModelName

Whereas It should be

from other_app.models import ModelName

How can I reconfigure Django path in PyCharm to use src directory as root for Dango apps/modules?

Upvotes: 3

Views: 889

Answers (1)

Mauricio Cortazar
Mauricio Cortazar

Reputation: 4213

In pycharm when you open a project you are setting the path environment var in the folder that you opened, in this case Project Directory, but you can change path in pycharm doing something like is described in this answer. Only add /src/ at the end of the path marked by (added by user)

Upvotes: 2

Related Questions