6👍
Try adding DJANGO_SETTINGS_MODULE=untitled.settings
to the environment variables listed in the configuration menu by clicking the dropdown titled ‘Django’ in your first photo.
31👍
If your IntelliJ is up to date, there is another solution.
I had the exact same problem in IntelliJ 2017.2 and it was driving me crazy until I read this post from a IntelliJ maintainer.
If you use IntelliJ Idea and "Load an existing project", it will model it as a Java project with a Python modules attached. You cannot get Django loaded, no matter what you do.
I handled this by purging the .idea
directory, and created a new Django project, with the pre-existing Django directory as the base directory in IntelliJ. I can now see Django in the project structure > project settings > module part of Intellij, and I can select the django settings file.
Step by step in pictures
- How to create a Django superuser if it doesn't exist non-interactively?
- Django 1.6: How to access static files in view
- Django & the "TemplateDoesNotExist" error
5👍
Problem Analysis in IntelliJ
The problem is whenever you import a python project in IntelliJ. It will load as java project and adjust itself into python language without changing the project type to python. So, IntelliJ thinks you are in java project even you are running python code in it and that’s the reason you are not allowed to switch to Django or any other python framework.
Here is the fix for that:
find the .iml
the file inside of .idea
folder or just inside of your project folder
and change module type from JAVA_MODULE
to PYTHON_MODULE
inside of .iml
file
Close the project and re-open your project and it will prompt you to configure your project as a Django project or whatever python framework you are using.
You also need to configure the framework inside of project_structure>module>(Your Framework)
For PyCharm
user make sure you have added the framework support to your imported project.
- Django File Upload and Rename
- Django template tag: How to send next_page in {url auth_logout}?
- Django Template Not Found
- How to install pygments on Ubuntu?
- Celerybeat not executing periodic tasks
0👍
This issue can also manifest in a situation where you have multiple modules and the django module isn’t the first one. It looks like intellij just picks the first one and the option for choosing the module is missing from the UI..
You can find .idea/workspace.xml
and find the run configuration, there’s a <module name="something" />
that you can edit to match the correct module name. Intellij musn’t be running when the value is edited.
Edit: It appears also to be possible to get past this by selecting "Use SDK of module" and selecting the django module.