Django and 'virtualenv' - proper project structure

Viewed 10178

I have a dilemma setting up a local development projet structure. Here is my setup:

  • Python 2.7
  • Django 1.9
  • Mac OSX El Capitan 10.11
  • MySQL 5.7

I made a "Mistake" of setting my project globally instead of in a virtual environment (using 'pip' to install everything in />). After reading this article I still don't get all the steps. Is this correct:

  1. I install global python ( pip, virtualenv in '/>' )
  2. I then go to a location where my projects will reside, like /users/user/documents/projects/project1 and from within 'project1' I use 'virtualenv' to create a virtual environment for this project (this creates a /virtual env/ folder inside /project1/ folder)
  3. activate this virtual environment and pip install django
  4. then from within newly created /virtual env/ folder I startprojectwhich creates another /project1/ folder within /virtual env/ folder
  5. with virtual environment still activated in the current shell session, I proceed with creating my scripts, site and app files

Ad 2. should the virtualenv folder be INSIDE the main "project1" folder or should it encompass it?

Ad 4. Is this correct or can I do it without activating virtual environment first?

My structure currently looks like this (starts from the root: /users/myUser/documents/projects/):

/project1/
    /website1/
        /static/
        /templates/
        __init.py__
        settings.py
        urls.py
        views.py
        wsgi.py
2 Answers
Related