Tags

, ,

young-game-match-kids.jpg

In a quest of being adept at working with data, understanding a languange / frameworks that works well in numbers manipulation is essential.

Python is a language vastly used within the datascience disciplines with lots of libraries and packages that support it.

Django is a web frontend framework that encourages rapid development with a clean pragmatic design

Before we get started, you’ll need to have;

 

Lets rumble

Installation of the above prerequisites,

Python :

python comes preinstalled in most os’s but you could always confirm your version using:

$ python
Python 3.6.0 (v3.6.0:41df79263a11, Dec 22 2016, 17:23:13)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type “help”, “copyright”, “credits” or “license” for more information.
>>>

if you see something like this, then python is installed. Exit this shell using :

ctrl + D

pip

pip is a package management system used to install and manage software packages written in Python.

virtualenv :

It is recommended that you use virtualenv to create isolated Python environments,

so you can use different package versions for different projects

install by Running the following command in your shell:

$ pip install virtualenv

after installing virtualenv,

setting up the environment

once through with the installations,

create a directory where your project will reside in move into it with :

$ mkdir myproject
$ cd myproject

create an isolated environment with :

$ virtualenv my_env

activate the virtual environment by running :

$ source my_env/bin/activate

the shell will now include the name of the active virtual environment enclosed in parenthesis like:

(my_env):myproject $

you can always deactivate environments with deactivate command.

using pip installed , get on installing Django with the following command,

(my_env):myproject $ pip install Django

to check that has been installed successfully, run:

(my_env):myproject $ python
>>> import django
>>> django.VERSION
(1, 10, 5, ‘final’, 0)
>>>

with an active environment, you can now embark on that project you are building.

start of project

run :

(my_env):myproject $ django-admin startproject mystic_falls

this creates a django project by the name ‘mystic_falls’* which has a basic structure

.(use whatever name you prefer for your project).

run the command below to work from project root folder and initialize application database :

(my_env)4bic:myproject $ cd mystic_falls
(my_env):mystic_falls $ python manage.py migrate

run server

The development server is ready to fire up, run:

(my_env):mystic_falls $ python manage.py runserver

on your browser, open http://127.0.0.1:8000/ , you should see:

.. “Welcome to Django” page.

You are now ready to create you own app.

Next Step : Creating an application

In Django, Applications provide some specific functionalities, think of the project as your website, which contains several applications like blog, wiki, or forum, which can be used in other projects.

 We’ll create an app in subsequent blog

Advertisements