Error starting Django in Intellij / Pycharm

I have a problem starting a Django server in Intellij / Pycharm (I tried in both).

There is a red cross:

enter image description here

And this is the error I get:

Error starting Django: select Django module

I have Python 2.7.10 and Django (via pip) installed on my computer. I tried reinstalling both python and Django, but that didn't help. I pointed out the sdk project (Python).

Edit:

This is what looks like on the Project Translator page.

enter image description here

and Django configuration:

enter image description here

+5
source share
2 answers

Try adding DJANGO_SETTINGS_MODULE=untitled.settings to the environment variables listed in the configuration menu by clicking the drop-down menu called "Django" in the first photo.

+1
source

If your IntelliJ is updated, there is another solution.

I had the same issue in IntelliJ 2017.2 and it drove me crazy until I read this post from an IntelliJ maintainer .

If you use IntelliJ Idea and “Load an Existing Project”, it will model it as a Java project with connected Python modules. You cannot load Django, no matter what you do.

I handled this by clearing the .idea directory and creating a new Django project , the previously existing Django directory being the base directory in IntelliJ. Now I can see Django in the project structure> project parameters> part of the Intellij module, and I can select the django settings file.

Step by step in the pictures

  • Delete .idea folder

  • Create a new project Create a new project

  • Choose Python> Django Choose Python> Django

  • Click next Click on

  • Select an existing django project path (or start from scratch with a new folder) Enter an existing project path

  • Add DJANGO_SETTINGS_MODULE=yourprojectname.settings to your launch configuration (can be found in the file yourprojectname/wsgi.py ).

Change startup configuration

Add env variable

Enjoy the development of Django 🚀

+5
source

Source: https://habr.com/ru/post/1247236/


All Articles