Django 101 By: Jason Sumner. Django Overview Django was started in 2003, released under BSD in 2005, and the Django Software Foundation was established.

Slides:



Advertisements
Similar presentations
How to Author MIRC Teaching File Documents. MIRC InfoRad Courses How to Set Up a Personal Teaching File System. How to Set Up a Personal Teaching File.
Advertisements

Samsung Smart TV is a web-based application running on an application engine installed on digital TVs connected to the Internet.
Rapid Web Development with Python/Django Julian Hill.
Presenter: James Huang Date: Sept. 29,  HTTP and WWW  Bottle Web Framework  Request Routing  Sending Static Files  Handling HTML  HTTP Errors.
Introduction to MVC Adding a View Page NTPCUG Tom Perkins, Ph.D.
1 Configuring Internet- related services (April 22, 2015) © Abdou Illia, Spring 2015.
Week 2 IBS 685. Static Page Architecture The user requests the page by typing a URL in a browser The Browser requests the page from the Web Server The.
Simple Web SQLite Manager/Form/Report
APACHE SERVER By Innovationframes.com »
Amazon EC2 Quick Start adapted from EC2_GetStarted.html.
Sharepoint Portal Server Basics. Introduction Sharepoint server belongs to Microsoft family of servers Integrated suite of server capabilities Hosted.
Web Development & Design Foundations with XHTML Chapter 9 Key Concepts.
Overview of Framework by Ahamed Rifaudeen A. page - i Steps before entering into the Framework?  Basic knowledge of object-oriented programming (OOP)
Linux Operations and Administration
Form Handling, Validation and Functions. Form Handling Forms are a graphical user interfaces (GUIs) that enables the interaction between users and servers.
Web Development Methodologies Yuan Wang(yw2326). Basic Concepts Browser/Server (B/S) Structure Keywords: Browser, Server Examples: Websites Client/Server.
 >> django-admin.py startproject mysite /mysite __init__.py manage.py settings.py urls.py.
Web Frameworks: Django Department of Biomedical Informatics University of Pittsburgh School of Medicine
A pro-Django presentation: Brandon W. King SoCal Piggies - May 2007.
Django Web Framework 김형용, 이정민 Framework 2.1. Django High-level Python Web Framework Develop fast Automate the repetitive stuff Follow best practices.
DAT602 Database Application Development Lecture 15 Java Server Pages Part 1.
® IBM Software Group © 2006 IBM Corporation Creating JSF/EGL Template Pages This section describes how to create.JTPL (Java Template Pages) using the Page.
1 Web Developer & Design Foundations with XHTML Chapter 6 Key Concepts.
Dj(T)ango with Python Ritika Virmani. What is Django? It’s not a Hawaiian dance Developed by Adrian Holovaty and Simon Willison Rapid Web Development.
Reading Data in Web Pages tMyn1 Reading Data in Web Pages A very common application of PHP is to have an HTML form gather information from a website's.
Department of Information Technology e-Michigan Web Development 0 HTML Form Creation in the Vignette Content Management Application.
건전지로 달리는 쟝고 세미나. 파트2 Last time MVC Views and URLconfs.
Chapter 1: Introduction to Web
London April 2005 London April 2005 Creating Eyeblaster Ads The Rich Media Platform The Rich Media Platform Eyeblaster.
London April 2005 London April 2005 Creating Eyeblaster Ads The Rich Media Platform The Rich Media Platform Eyeblaster.
DSpace UI Alexey Maslov. DSpace in general A digital library tool useful for storage, maintenance, and retrieval of digital documents Two types of interaction:
LiveCycle Data Services Introduction Part 2. Part 2? This is the second in our series on LiveCycle Data Services. If you missed our first presentation,
Topics Sending an Multipart message Storing images Getting confirmation Session tracking using PHP Graphics Input Validators Cookies.
Google App Engine Data Store ae-10-datastore
SAFARI ODBC INSTALLATION Go to the TRECA home WEB page.
D JANGO Leo Wang Daniel South Philip Kim. Introduction Open Source web application framework Released in 2005 Python is used throughout Speed of development.
WAMP Windows Apache MySQL and PHP i.e. “WAMP”. Why WAMP? WampServer is a Windows web development environment. It allows you to create and test web pages.
12/14/20151 Uniquescriptz Backend Support Document Ver 2.0.
Testing External Survey Automatic Credit Granting Shepherd University Department of Psychology.
LECTURE 14 Web Frameworks. WEB DEVELOPMENT CONTINUED Web frameworks are collections of packages or modules which allow developers to write web applications.
Session 1: Introduction to HTML Fall Today’s Agenda Talk about the functions of the Internet Cover useful terminology for today’s session HTML,
Developer Exam Preparation Thom Robbins Bryan Soltis
INTERNET APPLICATIONS CPIT405 Install a web server and analyze packets.
Multi-Domain Hosting CPTE 212 “Missing Slides” for 1/22/2015 John Beckett.
COMP 143 Web Development with Adobe Dreamweaver CC.
The Django Web Application Framework zhixiong.hong
1.Switch on the computer and wait for loading. 2.Select the Windows 7 OS at the end of the list. 3.Click on the link ‘Administrator’ 4.Enter the administrator.
Joomla Awdhesh Kumar Singsys Pte Ltd. What is Joomla? Joomla is an award-winning content management system (CMS), which enables you to build Web sites.
Installing and Configuring Moodle. Download Download latest Windows Install package from Moodle.orgMoodle.org.
1.Switch on the computer and wait for loading. 2.Select the Windows 7 OS at the end of the list. 3.Click on the link ‘Administrator’ 4.Enter the administrator.
How to Apply PDF in Flipbook on Website. Description If you are finding solution for applying PDF in flipbook mode on website, and adding multimedia items.
Intro to Django Peter Krenesky OSU Open Source Lab slides:
Intro to WordPress (Using XAMPP)
Overview Blogs and wikis are two Web 2.0 tools that allow users to publish content online Blogs function as online journals Wikis are collections of searchable,
CONTENT MANAGEMENT SYSTEM CSIR-NISCAIR, New Delhi
State of Testing Jason Kenny – ATS committer.
Play Framework: Introduction
Recitation – Week 8 Pranut jain.
To Join the Teleconference
Business mail account in yahoo
Django in the real world
Title: Tech Training Certificate: Ace of Initiative Program
Configuring Internet-related services
Add Image and Title to Individual Page
Django Users and Registration
Lecture 21 More On Django.
Client-Server Model: Requesting a Web Page
Query Interface using Django
Model View Controller (MVC)
Presentation transcript:

Django 101 By: Jason Sumner

Django Overview Django was started in 2003, released under BSD in 2005, and the Django Software Foundation was established in Object Relational Mapper engine that handles Models = relational database schema (models.py) Views = http request and web template system (views.py) Controller = Regex URL dispatcher (urls.py) Django Packages - Allows for third party components to be added available through pip CSRF, built in authentication, strong password storage, admin portal, and other out of the box features.

Preparation Download and Install Python 3.4 Install pip: $ sudo easy_install pip Install virtualenv $ pip install virtualenv

Create and Activate the Virtual Environment Create directory for your Django project and enter virtual environment $ virtualenv barcampdemo $ cd barcampdemo $ source bin/activate

Install Packages Install Django and database utility $ pip install django south $ pip freeze

Create Project and Establish Database Create new Django project and change directories $ django-admin.py startproject www $ cd www Establish Database $ python3 manage.py migrate

Create Admin User Create User $ python3 manage.py createsuperuser Start Server $ python3 manage.py runserver

Let’s Play With Some Code

Create first application Create an application called “signup” $ python3 manage.py startapp signup Notice the new folder and file structure created

settings.py Changes Add the following code to establish a templates folder: TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates’, 'DIRS': [os.path.join(BASE_DIR, '_templates')], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ 'django.template.context_processors.debug’, 'django.template.context_processors.request’, 'django.contrib.auth.context_processors.auth’, 'django.contrib.messages.context_processors.messages’, ], }, }, ]

settings.py Changes Add following code to establish a static folder: # Need when relocate to a web host # STATIC_ROOT = os.path.join(BASE_DIR, '_static’) STATICFILES_DIRS = ( os.path.join(BASE_DIR, '_static'), ) Change following lines: DEBUG = False ALLOWED_HOSTS = ['localhost',' '] Add new application to INSTALLED_APPS: 'signup’, 'signup’,

views.py Modify views.py from django.shortcuts import render, render_to_response, RequestContext from django.contrib import messages def home(request): # Render page return render_to_response(”index.html", locals(), context_instance=RequestContext(request)) return render(request, ”index.html", context) Create index.html landing page and signupform.html form page

models.py Models define the import uuid class signupModel(models.Model): first_name = models.CharField(max_length=120, null=False, blank=False) last_name = models.CharField(max_length=120, null=False, blank=False) _address = models. Field(max_length=120, null=False, blank=False) tech256_username = models.CharField(max_length=120, null=True, blank=True) webste_url = models.URLField(max_length=200, null=True, blank=True) # Define variables for option newsletter_no = 'NO’ newsletter_yes = 'YES’ newsletter_options = ( (newsletter_no, 'No - I hate junk '), (newsletter_yes, 'Yes - Send it to my spam account'), ) # Default database column/type and reference variables defined above newsletter_preference = models.CharField(max_length=4, choices=newsletter_options, default=newsletter_yes) talk_description = models.TextField(null=False, blank=False) active = models.BooleanField(default=True) sid = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False def __str__(self): return self.sid Once defined, make the migrations: $ python3 manage.py makemigrations $ python3 manage.py migrate

forms.py Create a new file called “forms.py” under the Application folder. from django import forms from.models import signupModel class SignupForm(forms.ModelForm): class Meta: model = signupModel fields = ['first_name','last_name',' _address','tech256_use rname','webste_url','newsletter_preference’,'talk_des cription','active']

Modify views.py Modify views.py: # Create your views here. from django.shortcuts import render, render_to_response, RequestContext from django.contrib import messages from.forms import SignupForm def home(request): form = SignupForm(request.POST or None) if request.method=="POST”: if form.is_valid(): human = True save_it = form.save(commit=False) save_it.save() messages.success(request,"Thank you for registering!”) else: form = SignupForm(request.POST or None) messages.error(request,"Uh oh! Correct the errors below.") else: form = SignupForm(request.POST or None) # Render page return render_to_response(”signupform.html", locals(), context_instance=RequestContext(request)) return render(request, ”signupform.html", context)

Create Templates index.html {% if messages %} {% for message in messages %} {{ message }} {% endfor %} {% endif %} {% block content %}{% endblock %} {% if messages %} {% for message in messages %} {{ message }} {% endfor %} {% endif %} {% block content %}{% endblock %}signuform.html {% extends 'index.html' %} {% block content %} {% csrf_token %} {{ form.as_p }} {% endblock %}

admin.py Add the following code to register in Admin Portal from.models import signupModel class signupAdmin(admin.ModelAdmin): list_display = ["sid","first_name","last_name"," _address","tec h256_username”] class Meta: model = signupModel admin.site.register(signupModel, signupAdmin)

Apply A Template Copy over static items to _static folder. Copy HTML Code over to index.html and place form. Modify path to _static folder URL. Modify CSS to correct elements. View in Desktop and Mobile formats.

Resources HTML5 UP – “Prologue” Theme Django Project Justin Mitchell/Coding Entrepreneurs - sfXFp6DpzRcd-q4vR5qAgOZUuz8041S sfXFp6DpzRcd-q4vR5qAgOZUuz8041S sfXFp6DpzRcd-q4vR5qAgOZUuz8041S Python Django Packages -

Questions