Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python

Should I start virutalenv first or run django-admin startproject <PROJECTNAME> when starting a new project?

I am starting a new Django project, so I created a new directory, my_project/, and then activated Virtualenv. I then installed Django to that project with pip install django. I was about to run django-admin startproject my_project when I realized that it would create another directory within my_project/, so I stopped, which brings me to the question above.

1 Answer

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 68,441 Points

It more likely to run virtualenv first so that you can install django. The virtualenv creates directories that added to the exec PATH.

If you already have a my_project directory and don't want the extra level of hierarchy created by django-admin project you can add a "dot" for "current working directory":

django-admin startproject my_project .

The manage.py, etc. will all be placed in this directory. The "my_project` in this command will be the name of the sub-directory. More at Docs

Thanks, Chris! That worked out really well. That third directory was really confusing when I was trying to program my_project. I've seen started a new one using ..