Skip to content
Home » How to start a Django project in an existing folder

How to start a Django project in an existing folder

Django has become my favorite web development framework. It’s Python-based and in a couple of minutes you can deploy your first app. A problem I ran into when building my first apps was that I seemingly had to create a subfolder to start a new project.

To create a new project, one typically uses the following command.

django-admin startproject <YOUR_PROJECT_NAME>

This command creates a new project within the existing folder. However, if you’re working within a git repository, you might not want to have your project skeleton in a subfolder. And if you thought you could just run the command one level higher, you’re in for a bad surprise. The following error will be shown:

CommandError: 'path/to/YOUR_PROJECT_NAME' already exists

Although it’s not documented in the official documentation, the solution, however, is extremely simple. You just add a dot to Django’s startproject command, which uses the command’s [directory] argument.

django-admin startproject <YOUR_PROJECT_NAME> .

Now go on, go work on your new project!

Say thanks, ask questions or give feedback

Technologies get updated, syntax changes and honestly… I make mistakes too. If something is incorrect, incomplete or doesn’t work, let me know in the comments below and help thousands of visitors.

1 thought on “How to start a Django project in an existing folder”

Leave a Reply

Your email address will not be published. Required fields are marked *