Django Basics



Django Basics

6 0


Django-basics

A Basic Django Presentation

On Github stalwart201 / Django-basics

Django Basics

Contributors Rishabh Singh / @stalwart201Shashank Aryan / @arlok31Shweta Suman / @cosmologist10Mannu Gupta / @theparadoxer02Shashank Kumar / @realslimshankyShivam Sharma / @shivams334

What is Django?

Why Django

  • Ridiculously fast
  • Fully loaded
  • Reassuringly secure
  • Exceedingly scalable
  • Incredibly versatile

what is Framework?

  • A web framework (WF) or web application framework (WAF) is a software that is designed to support the development of web applications
  • It includes web services, web resources and web APIs. Web frameworks aim to alleviate the overhead associated with common activities performed in web development

Types of Framework

  • Oracle Application Development Framework
  • Financial modeling applications
  • Earth system modeling applications
  • Decision support systems
  • Multimedia framework - Media playback and authoring
  • Ajax framework / JavaScript framework
  • Web framework
  • Application framework - General GUI applications
  • Middleware
  • Cactus Framework - High performance scientific computing
  • Enterprise Architecture framework

Various other Web frameworks on Python.

  • Flask
  • Bottle
  • Zope
  • Pyramid
  • CubicWeb
  • Web.py
  • Web2.py

Installing Django

  • Install pip
  • Install Django via pip

Installing pip on Linux

  • For Fedora users:
  • $ sudo dnf install pip

For Debian users: $ sudo apt-get install pip

Installing Django on Linux

$ sudo pip install django

To check the instaled version of Django on Linux

$ pyhton -m django --version

Creating a project on Django

Create a directory named Django Open the path in terminal

$ django-admin startproject mysite 'mysite' is the name of the project

Obtain repo

git init

git clone "url"

Installing Django on Linux

$ sudo pip install django

To check the instaled version of Django on Linux

$ pyhton -m django --version

Creating a project on Django

Create a directory named Django Open the path in terminal

$ django-admin startproject mysite 'mysite' is the name of the project

Obtain repo

git init

git clone "url"

Installing Django on Linux

$ sudo pip install django

To check the installed version of Django on Linux

$ pyhton -m django --version

Creating a project on Django

Create a directory named Django Open the path in terminal

$ django-admin startproject mysite 'mysite' is the name of the project

Creating an app in Django Project

The django project is made up of different apps In Terminal change your working directory to Django Project directory Type the following code

$ python manage.py startapp 'Appname'

Urls in django

A URL is simply a web address You can see a URL every time you visit a website It is visible in your browser's address bar urls.py file is made in mysite folder to link all urls

Views in Django

A view function, or view for short, is simply a Python function that takes a Web request and returns a Web response This response can be the HTML content of a Web page, or a redirect, or a 404 error, or an XML document, or an image or anything

What is a Template ?

A template is simply a text file. It can generate any text-based format (HTML, XML, CSV, etc.) A template contains variables, which get replaced with values when the template is evaluated, and tags These tags control the logic of the template

Forms handling in django

Display an HTML form with automatically generated form widgets (like a text field or date picker) Check submitted data against a set of validation rules Redisplay a form in case of validation errors Convert submitted form data to the relevant Python data types

Django admin site

To add, edit and delete the posts we've just modeled, we will use Django admin The admin is enabled in the default project template used by startproject To Register a model to the Admin

from django.contrib import admin

from .models import model

admin.site.register(Modelame)

Books/Blogs References

Below are some references you should go to get in-depth knowledge about Django

Django Girls Tutorial

Two Scoops Of Django

Tango With Django

Mastering Django

Videos References

Below are some video series that will give you a headstart in Django

Coding Entrepreneurs - Try Django

The New Boston - Django Tutorials for Beginners

Sentdex - Django Web Development with Python

Mike Hibbert - Python Django tutorial

Thank You

Django Basics Contributors Rishabh Singh / @stalwart201 Shashank Aryan / @arlok31 Shweta Suman / @cosmologist10 Mannu Gupta / @theparadoxer02 Shashank Kumar / @realslimshanky Shivam Sharma / @shivams334