Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Copyright © 2017, edureka and/or its affiliates. All rights reserved. Agenda Why Django framework? What is Django? Architecture: MVC-MVT Pattern Hands On: Get Started With Django Building Blocks of Django Project: A Web Application 1 2 3 4 5 6
Copyright © 2017, edureka and/or its affiliates. All rights reserved. Why Django Framework? First, let’s understand how Django came into existence
Copyright © 2017, edureka and/or its affiliates. All rights reserved. Why Django Framework? ❑ Django is a Python web framework ❑ A framework provides a structure and common methods to make the life of a web application developer much easier for building flexible, scalable and maintainable web applications
Copyright © 2017, edureka and/or its affiliates. All rights reserved. Why Django Framework? ➢ A Python web framework is a code library that provide tools and libraries to simplify common web development operations.
Copyright © 2017, edureka and/or its affiliates. All rights reserved. What is Django?
Copyright © 2017, edureka and/or its affiliates. All rights reserved. What is Django? Django is a high-level and has a MVC- MVT styled architecture. Django web framework is written on quick and powerful Python language. Django has a open-source collection of libraries for building a fully functioning web application.
Copyright © 2017, edureka and/or its affiliates. All rights reserved. Features of Django F U L LY L O A D E D F A S T S E C U R E S C A L A B L E
Copyright © 2017, edureka and/or its affiliates. All rights reserved. Django MVC-MVT Pattern
Copyright © 2017, edureka and/or its affiliates. All rights reserved. Django MVC-MVT Pattern ➢ MVC is slightly different from MVT as Django itself takes care of the Controller part. ➢ It leaves the template which is a HTML file mixed with Django Template Language (DTL). Model View Template Model View Controller Request MVC MVT
Copyright © 2017, edureka and/or its affiliates. All rights reserved. Model View Controller The developer provides the Model, the view and the template then just maps it to a URL and Django does the magic to serve it to the user.
Copyright © 2017, edureka and/or its affiliates. All rights reserved. Hands on Now, let’s create a basic Web App
Copyright © 2017, edureka and/or its affiliates. All rights reserved. Installation Go to the link: https://www.djangoproject. com/download/ 1 2 Install the latest version of Django
Copyright © 2017, edureka and/or its affiliates. All rights reserved. Create a Project $ django-admin startproject firstproject Open the terminal and navigate to the folder where the project is to be created. Firstproject/ manage.py firstproject/ __init__.py settings.py urls.py wsgi.py This will create a "myproject" folder with the following structure: 1 2
Copyright © 2017, edureka and/or its affiliates. All rights reserved. Project Structure “firstproject” folder is just your project container or directory. You can rename it to anything you like. firstproject/ firstproject __init__.py settings.py urls.py wsgi.py manage.py
Copyright © 2017, edureka and/or its affiliates. All rights reserved. Project Structure This folder is the actual python package of your project which contains some default files. firstproject/ firstproject __init__.py settings.py urls.py wsgi.py manage.py
Copyright © 2017, edureka and/or its affiliates. All rights reserved. Project Structure It is an empty file that tells python that this folder should be treated as package. firstproject/ firstproject __init__.py settings.py urls.py wsgi.py manage.py
Copyright © 2017, edureka and/or its affiliates. All rights reserved. Project Structure This contains the settings or the configurations of the project. firstproject/ firstproject __init__.py settings.py urls.py wsgi.py manage.py
Copyright © 2017, edureka and/or its affiliates. All rights reserved. Project Structure This file contains all the links of your project and the function to call. firstproject/ firstproject __init__.py settings.py urls.py wsgi.py manage.py
Copyright © 2017, edureka and/or its affiliates. All rights reserved. Project Structure It is an entry point for WSGI-compatible web services to serve your project. firstproject/ firstproject __init__.py settings.py urls.py wsgi.py manage.py
Copyright © 2017, edureka and/or its affiliates. All rights reserved. Project Structure It is a command line utility that lets you interact with the Django project. firstproject/ firstproject __init__.py settings.py urls.py wsgi.py manage.py
Copyright © 2017, edureka and/or its affiliates. All rights reserved. Your First Web App Congratulations! We have successful created a basic Web App.
Copyright © 2017, edureka and/or its affiliates. All rights reserved. Components of Django Now, let’s understand the components/ building blocks of Django
Copyright © 2017, edureka and/or its affiliates. All rights reserved. Building Blocks of Django ORM URLs and Views Templates Forms Authentication Admin Internationalization Security ORM stands for Object-relational Mapper. Define your data models. You get a rich, dynamic database-access API for free but you can still write SQL if needed. from django.db import models Class employees(models.Model): firstname = models.CharField(max_length=10) Lastname = models.CharField(max_length=10) def _str_(self): return self.firstname
Copyright © 2017, edureka and/or its affiliates. All rights reserved. URLs and Views ORM Templates Forms Authentication Admin Internationalization Security Like a table of contents for your app, it contains a simple mapping between URL patterns and your views. from Django.shortcuts import render def index(request): return HttpResponse (<h2> Hey! Welcome to Django tutorial</h2>) from django.conf.urls import url from . import views urlpatterns = [ url(r'^$', views.index, name='index'), ] URL Mapping views and URL Building Blocks of Django
Copyright © 2017, edureka and/or its affiliates. All rights reserved. Building Blocks of Django Templates ORM URLs and Views Forms Authentication Admin Internationalization Security Templates are designed to feel comfortable and for those who work with HTML, like designers and front-end developers. TEMPLATE_DIRS = ( '<workspace>/django_project/templates/', )
Copyright © 2017, edureka and/or its affiliates. All rights reserved. Building Blocks of Django Forms ORM URLs and Views Templates Authentication Admin Internationalization Security Django provides a powerful form library that handles rendering forms as HTML, validating user-submitted data, and converting that data to native Python types.
Copyright © 2017, edureka and/or its affiliates. All rights reserved. Building Blocks of Django Authentication ORM URLs and Views Templates Forms Admin Internationalization Security It handles user accounts, groups, permissions and cookie-based user sessions. from django.contrib.auth.decorators import login_required from django.shortcuts import render @login_required def my_protected_view(request): return render(request, 'protected.html', {'current_user': request.user})
Copyright © 2017, edureka and/or its affiliates. All rights reserved. Building Blocks of Django Admin ORM URLs and Views Templates Forms Authentication Internationalization Security It is the most powerful part that reads metadata in your models to provide a powerful and production-ready interface that can be used to manage content on your site.
Copyright © 2017, edureka and/or its affiliates. All rights reserved. Building Blocks of Django Internationalization ORM URLs and Views Templates Forms Authentication Admin Security Django offers full support for translating text into different languages, plus locale-specific formatting of dates, times, numbers and time zones.
Copyright © 2017, edureka and/or its affiliates. All rights reserved. Building Blocks of Django Security ORM URLs and Views Templates Forms Authentication Admin Internationalization ✓ Clickjacking ✓ Cross-site scripting ✓ Cross Site Request Forgery (CSRF) ✓ SQL injection ✓ Remote code execution Django provides multiple protections against:
Copyright © 2017, edureka and/or its affiliates. All rights reserved. Project
Copyright © 2017, edureka and/or its affiliates. All rights reserved. Session In A Minute Django Framework ProjectComponentsHands On ArchitectureWhat is Django
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Django Tutorial | Django Web Development With Python | Django Training and Certification | Edureka

Django Tutorial | Django Web Development With Python | Django Training and Certification | Edureka

  • 1.
    Copyright © 2017,edureka and/or its affiliates. All rights reserved.
  • 2.
    Copyright © 2017,edureka and/or its affiliates. All rights reserved. Agenda Why Django framework? What is Django? Architecture: MVC-MVT Pattern Hands On: Get Started With Django Building Blocks of Django Project: A Web Application 1 2 3 4 5 6
  • 3.
    Copyright © 2017,edureka and/or its affiliates. All rights reserved. Why Django Framework? First, let’s understand how Django came into existence
  • 4.
    Copyright © 2017,edureka and/or its affiliates. All rights reserved. Why Django Framework? ❑ Django is a Python web framework ❑ A framework provides a structure and common methods to make the life of a web application developer much easier for building flexible, scalable and maintainable web applications
  • 5.
    Copyright © 2017,edureka and/or its affiliates. All rights reserved. Why Django Framework? ➢ A Python web framework is a code library that provide tools and libraries to simplify common web development operations.
  • 6.
    Copyright © 2017,edureka and/or its affiliates. All rights reserved. What is Django?
  • 7.
    Copyright © 2017,edureka and/or its affiliates. All rights reserved. What is Django? Django is a high-level and has a MVC- MVT styled architecture. Django web framework is written on quick and powerful Python language. Django has a open-source collection of libraries for building a fully functioning web application.
  • 8.
    Copyright © 2017,edureka and/or its affiliates. All rights reserved. Features of Django F U L LY L O A D E D F A S T S E C U R E S C A L A B L E
  • 9.
    Copyright © 2017,edureka and/or its affiliates. All rights reserved. Django MVC-MVT Pattern
  • 10.
    Copyright © 2017,edureka and/or its affiliates. All rights reserved. Django MVC-MVT Pattern ➢ MVC is slightly different from MVT as Django itself takes care of the Controller part. ➢ It leaves the template which is a HTML file mixed with Django Template Language (DTL). Model View Template Model View Controller Request MVC MVT
  • 11.
    Copyright © 2017,edureka and/or its affiliates. All rights reserved. Model View Controller The developer provides the Model, the view and the template then just maps it to a URL and Django does the magic to serve it to the user.
  • 12.
    Copyright © 2017,edureka and/or its affiliates. All rights reserved. Hands on Now, let’s create a basic Web App
  • 13.
    Copyright © 2017,edureka and/or its affiliates. All rights reserved. Installation Go to the link: https://www.djangoproject. com/download/ 1 2 Install the latest version of Django
  • 14.
    Copyright © 2017,edureka and/or its affiliates. All rights reserved. Create a Project $ django-admin startproject firstproject Open the terminal and navigate to the folder where the project is to be created. Firstproject/ manage.py firstproject/ __init__.py settings.py urls.py wsgi.py This will create a "myproject" folder with the following structure: 1 2
  • 15.
    Copyright © 2017,edureka and/or its affiliates. All rights reserved. Project Structure “firstproject” folder is just your project container or directory. You can rename it to anything you like. firstproject/ firstproject __init__.py settings.py urls.py wsgi.py manage.py
  • 16.
    Copyright © 2017,edureka and/or its affiliates. All rights reserved. Project Structure This folder is the actual python package of your project which contains some default files. firstproject/ firstproject __init__.py settings.py urls.py wsgi.py manage.py
  • 17.
    Copyright © 2017,edureka and/or its affiliates. All rights reserved. Project Structure It is an empty file that tells python that this folder should be treated as package. firstproject/ firstproject __init__.py settings.py urls.py wsgi.py manage.py
  • 18.
    Copyright © 2017,edureka and/or its affiliates. All rights reserved. Project Structure This contains the settings or the configurations of the project. firstproject/ firstproject __init__.py settings.py urls.py wsgi.py manage.py
  • 19.
    Copyright © 2017,edureka and/or its affiliates. All rights reserved. Project Structure This file contains all the links of your project and the function to call. firstproject/ firstproject __init__.py settings.py urls.py wsgi.py manage.py
  • 20.
    Copyright © 2017,edureka and/or its affiliates. All rights reserved. Project Structure It is an entry point for WSGI-compatible web services to serve your project. firstproject/ firstproject __init__.py settings.py urls.py wsgi.py manage.py
  • 21.
    Copyright © 2017,edureka and/or its affiliates. All rights reserved. Project Structure It is a command line utility that lets you interact with the Django project. firstproject/ firstproject __init__.py settings.py urls.py wsgi.py manage.py
  • 22.
    Copyright © 2017,edureka and/or its affiliates. All rights reserved. Your First Web App Congratulations! We have successful created a basic Web App.
  • 23.
    Copyright © 2017,edureka and/or its affiliates. All rights reserved. Components of Django Now, let’s understand the components/ building blocks of Django
  • 24.
    Copyright © 2017,edureka and/or its affiliates. All rights reserved. Building Blocks of Django ORM URLs and Views Templates Forms Authentication Admin Internationalization Security ORM stands for Object-relational Mapper. Define your data models. You get a rich, dynamic database-access API for free but you can still write SQL if needed. from django.db import models Class employees(models.Model): firstname = models.CharField(max_length=10) Lastname = models.CharField(max_length=10) def _str_(self): return self.firstname
  • 25.
    Copyright © 2017,edureka and/or its affiliates. All rights reserved. URLs and Views ORM Templates Forms Authentication Admin Internationalization Security Like a table of contents for your app, it contains a simple mapping between URL patterns and your views. from Django.shortcuts import render def index(request): return HttpResponse (<h2> Hey! Welcome to Django tutorial</h2>) from django.conf.urls import url from . import views urlpatterns = [ url(r'^$', views.index, name='index'), ] URL Mapping views and URL Building Blocks of Django
  • 26.
    Copyright © 2017,edureka and/or its affiliates. All rights reserved. Building Blocks of Django Templates ORM URLs and Views Forms Authentication Admin Internationalization Security Templates are designed to feel comfortable and for those who work with HTML, like designers and front-end developers. TEMPLATE_DIRS = ( '<workspace>/django_project/templates/', )
  • 27.
    Copyright © 2017,edureka and/or its affiliates. All rights reserved. Building Blocks of Django Forms ORM URLs and Views Templates Authentication Admin Internationalization Security Django provides a powerful form library that handles rendering forms as HTML, validating user-submitted data, and converting that data to native Python types.
  • 28.
    Copyright © 2017,edureka and/or its affiliates. All rights reserved. Building Blocks of Django Authentication ORM URLs and Views Templates Forms Admin Internationalization Security It handles user accounts, groups, permissions and cookie-based user sessions. from django.contrib.auth.decorators import login_required from django.shortcuts import render @login_required def my_protected_view(request): return render(request, 'protected.html', {'current_user': request.user})
  • 29.
    Copyright © 2017,edureka and/or its affiliates. All rights reserved. Building Blocks of Django Admin ORM URLs and Views Templates Forms Authentication Internationalization Security It is the most powerful part that reads metadata in your models to provide a powerful and production-ready interface that can be used to manage content on your site.
  • 30.
    Copyright © 2017,edureka and/or its affiliates. All rights reserved. Building Blocks of Django Internationalization ORM URLs and Views Templates Forms Authentication Admin Security Django offers full support for translating text into different languages, plus locale-specific formatting of dates, times, numbers and time zones.
  • 31.
    Copyright © 2017,edureka and/or its affiliates. All rights reserved. Building Blocks of Django Security ORM URLs and Views Templates Forms Authentication Admin Internationalization ✓ Clickjacking ✓ Cross-site scripting ✓ Cross Site Request Forgery (CSRF) ✓ SQL injection ✓ Remote code execution Django provides multiple protections against:
  • 32.
    Copyright © 2017,edureka and/or its affiliates. All rights reserved. Project
  • 33.
    Copyright © 2017,edureka and/or its affiliates. All rights reserved. Session In A Minute Django Framework ProjectComponentsHands On ArchitectureWhat is Django
  • 34.
    Copyright © 2017,edureka and/or its affiliates. All rights reserved.