Tuesday, June 26, 2018

Setting up Django Project: Part 1

Environment:

  • Visual Studio Code
  • MAC OSX

Frameworks:

  • Django
  • Bootstrap (UI)
  • Python 3.6
  • CondaMini for Virtual Environment
  • Github for version control


Preset:

  • Visual Studio Code already installed


Step 1: Create a new folder

Step 2: Install miniconda for setting up the virtual environment

  • https://conda.io/miniconda.html

Step 3: Install and Test Conda

  • Open Terminal in VS Code and run conda --version
  • Re-start Terminal by typing exit whether you are using builtin VS Code terminal or regular terminal window
  • Type conda --version to verify conda installed 
  • If you see conda 4.5.4 or something similar, conda is working
  • Getting started guide with conda https://conda.io/docs/user-guide/getting-started.html 


Step 4 : Create a virtual environment with Django

  • conda create --name [envName] django
  • Select yes to download and create the virtual environment


Step 5: Activate / Deactivate virtual environment

  • Once the virtual environment is created use
  • source activate [envName]
  • to deactivate: source deactivate
  • the keyword source is required on MAC OS
Step 5(a): Checking for existing virtual environments [Edited]

  • conda info --env
  • You can see which virtual environments have been created using the above command. We can see two
  • The one with the * is the active one

base                  *  /Users/shamyl/miniconda3
SLS                      /Users/shamyl/miniconda3/envs/SLS
                         /anaconda3/envs/myEnv

Step 6: Create first Django Project
  • django-admin startproject [projectName]


Step 7: Create an app within your django project
  • python mange.py stratapp [appName]

Step 8: Run your server and test it out

  • python manage.py runserver



Step 9: Create GIT Repository and commit to Master
  • I'm using GitHub Desktop
  • Created a new repository
  • Gave it a name and pointed it to the local directory where the project is saved
  • Gave a summary and description and pressed the commit to master button to create the first master

No comments:

Post a Comment