Force django-admin startproject if project folder already exists

Question:

I want to start new django project in already existing folder and obviously get

CommandError: '/home/user/projectfolder' already exists.

Is there some way to force startproject command to create project in an existing folder? I have some important data in that folder and also git folder so I don’t want to move it somewhere and then move it back.

Asked By: valignatev

||

Answers:

Just use the current directory:

cd /home/user/projectfolder

django-admin.py startproject project .

The use of . just instructs Django to create a project in the current directory while:

django-admin.py startproject

instructs Django to create a project and create the necessary directory

If only the project name is given, both the project directory and
project package will be named and the project directory
will be created in the current working directory.

This fails because of the existing directory which is not a bug but a constrain in order to prevent accidents.

Answered By: petkostas

You can make too like this:

 django-admin startproject name_project path_project 

Example:

 django-admin startproject example /tmp/example 
Answered By: Elinaldo Monteiro
django-admin startproject project-name . (add . after the command followed by space)
Answered By: Tintin
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.