Python commands for Mac and Windows
Python commands
To check Python version enter command
Python3 – – version
To check with pip version
Pip3 —version
To check diesel version enter the command following
Django-admin —version
Install Django
We can install the Django in two types first we can install in virtual environment second we can install globally. In virtual environment if we install the Django it will not be accessible outside of this environment.
Install Django in Separate Environment
Install virtual environment wrapper
This is used to install virtual environment wrapper.
Pip install virtualenvwrapper-win
Example:-
(In windows ) pip install virtualenvwrapper
(in MacOS) pip3 install virtualenvwrapper
Create virtual environment (VE)
This is used to create virtual environment. It will automatically activate environment.
For windows:-
mkvirtualenv envname
For example :-
mkvirtualenv ckesripyvrenv
For my macOS:-
Step 1.
python3 -m venv envname
For example :- python3 -m venv ckesripyvrenv
Step 2
Source envname/bin/activate
For example :- source ckesripyvrenv/bin/activate
Step 3: If we want to deactivate virtual env.
deactivate envname
Step4: remove env
rm -r bin include lib lib64 pyvenv.cfg share
Active VE
This is used to activate environment.
workon envname
For example :-
workon ckesripyvrenv
Installed Django in created VE
Pip install django
First activate environment then run the command to install django within active environment. You can also specify version pip install django == 2.0
Django Versions
django-admin —version
Create Project in django
Create Django Project
django-admin startproject projectname
Example
django-admin startproject schoolproject
Run Django Project
First goto the project root directory then run the below command
python manage.py runserver
optional command for, if we want to run project on specific port (for example 5555) then use below command
python manage.py runserver 5555
Stop Django Project
Press Ctrl+c
Create App in your django Project
To create app in your project, you have to move in your Project’s root directory. Root directory is the
Uninstall Virtual environment wrapper
Step 1. Open command prompt
Step 2. Pip uninstall virtualenvwrapper