Cannot successfully create Django project with IDEA 15.0.2

Answered

I'm brand new to Python and have been trying to figure out how to set up a Python project with IDEA.

dialog1.JPG
Here I've set my application name to main. In the second dialog I leave the Flask checkbox unchecked.

dialog2.JPG
Here, django-demo is the folder where the virtual enivronment lives. Based on https://www.jetbrains.com/pycharm/help/creating-and-running-your-first-django-project.html I expect the result to be the equivalent of starting in my django-demo folder and running the commands

django-admin startproject demo
cd demo
python manage.py startapp main


That should give me folders like this:

django-demo
|-demo
  |-demo
    |-__init__.py
    |-settings.py
    ...etc
  |-main
    |-migrations
    |-__init__.py
    |-admin.py
    ...etc
  |-manage.py


However, what I get is an error: "CommandError: 'demo' conflicts with the name of an existing Python module and cannot be used as a project name. Please try another name." and the process fails. The demo folder doesn't have anything beyond the .iml and the .idea folder. Since I can't see what commands IDEA is running and since I'm really new to Python I don't know if this is a bug or if I'm missing something.

4 comments
Comment actions Permalink

Try using some other name instead of "demo".

0
Comment actions Permalink

I have tried several different names including 'areyoukiddingme.' It doesn't matter what name I choose. I get the same error. The shell commands in my post do work. I did get the same error on the command line once by accident.

django-admin startproject demo
cd demo
django-admin startproject demo


That gives exactly the same error I see from IDEA. The error that is reported is coming from the Python interpreter. I can post a screen shot of that if it will help.

0
Comment actions Permalink

Do you create a new project from IDEA in a directory with already existing project? It will not work, please create a new project in IDEA in a completely emptry folder.

0
Comment actions Permalink

I was starting from a completely empty folder.

I seem to have found the problem. I was just on the Flask web site looking at their installation guide and they set up their project with the project folder as a sibling of the virtual environment folder like this:

django-demo
|-venv
|-demo
  |-demo
  |-main


The first tutorial on Django I watched had the project folder inside the virtual environment folder...at least that is what I inferred. I just watched it again and it's actually unclear what he's doing.

Once I set the folders up this way, it works. The project and app files are scaffolded as I expected.

0

Please sign in to leave a comment.