Getting Started with Django2 and Python3

Getting Started with Django2 and Python3

June 11, 2018
3 minutes read time
0 likes
0 comments
390 times viewed


header image

Description

This article will let you get started with Django2 using Python3. It will make you familiar with the concept of virtual environment. Django is the web development framework for Python.

Content

Django2 is only supported by python3, Django-1.11.x was the last version of Django supported by python2. To use django2 you need it to use using python3.

I strongly recommend using virtual environment for all django development.

You can follow this process:

Install pip3

$sudo apt-get install python3-pip

Install Virtual Environment for Python3

$sudo pip3 install virtualenv

Create a project directory

$mkdir ~/newproject
$cd ~/newproject

Create a new virtual environment and activate it

In this environment pip by default is pip3 and python by default is python3.

$virtualenv .venv
$source .venv/bin/activate

After environment is activated, terminal will be preceeded with (.venv)$ or your virtual environment name.

Now Install Django

(.venv)$pip install django

Check Django Version

(.venv)$django-admin --version

Create project and start

(.venv)$django-admin startproject my_project

(.venv)$cd my_project

(.venv)$python manage.py runserver

Stop the server

To stop the development servert just hit Ctrl+C.

Deactivate Environment

To deactivate the environment.

(.venv)$deactivate

And again terminal will be like.

$

Thank you!!!



We are done



Like this post

0   Like


Share this post on

Google Plus LinkedIn


About the author




Join the discussion

Nothing to preview

Post Comment



Comments