Django - The Web framework for perfectionists with deadlines

Post on 17-May-2015

1032 Views

Category:

Technology

1 Downloads

Preview:

Click to see full reader

DESCRIPTION

Django ist ein in Python programmiertes Framework, dass die schnelle Entwicklung von Web-Applikationen ermöglicht. Dabei wird Wert auf sauberen Code und die Wiederverwendbarkeit von einzelnen Komponenten gelegt. Der Vortrag wurde beim Webmontag Leipzig im März 2010 gehalten.

Transcript

The Web frameworkfor perfectionists with deadlines

Markus Zapke-GründemannWebmontag Leipzig 29.03.2010

• Über mich

• Was ist Django?

• Python

• Architektur

• Django in freier Wildbahn

• Django in Deutschland

• Weiterführende Links

• DjangoCon Europe

• Workshop in Leipzig

Übersicht

MarkusZapke-Gründemann• Softwareentwickler seit 2001

• Schwerpunkt: Web Application Development mit Python und PHP

• Django, Symfony & Zend Framework

• Freier Softwareentwickler und Berater seit 2008

• www.keimlink.de

Was ist Django?

Jean "Django" Reinhardt23.1.1910 - 16.5.1953

Bildquelle: http://en.wikipedia.org/wiki/File:Django9.jpg

• Web Application Framework

• In Python geschrieben

• Open Source Software (BSD Lizenz)

• Django Software Foundation

• Umfangreiche Dokumentation

• Große, freundliche Community

Was ist Django?

• Rapid Development

• Loose Coupling

• Wiederverwendbare Applikationen

• Don't Repeat Yourself (DRY)

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

http://c2.com/cgi/wiki?DontRepeatYourself

Was ist Django?

Und natürlich Ponies!

Ponies?

Ponies?

The Python logo is a trademark of the Python Software Foundation.

Guido van Rossum begann 1989 mit der Entwicklung von Python

Bildquelle: http://commons.wikimedia.org/wiki/File:Guido_van_Rossum_OSCON_2006.jpg

Objektorientierte Sprache

class Input(Widget): """ Base class for all <input> widgets (except type='checkbox' and type='radio', which are special). """ input_type = None # Subclasses must define this.

def render(self, name, value, attrs=None): if value is None: value = '' final_attrs = self.build_attrs(attrs, type=self.input_type, name=name) if value != '': # Only add the 'value' attribute if a value is non-empty. final_attrs['value'] = force_unicode(formats.localize_input(value)) return mark_safe(u'<input%s />' % flatatt(final_attrs))

Große StandardbibliothekBildquelle: http://www.flickr.com/photos/jhoweaa/327651705/

Unit TestingBildquelle: http://www.flickr.com/photos/sidelong/246816211/

Alle Logos und Warenzeichen auf dieser Seite sind Eigentum der jeweiligen Besitzer und Lizenzhalter.

Viele Betriebssysteme

Gutes ProgrammierwerkzeugBildquelle: http://www.flickr.com/photos/philentropist/176054470/

Freie SoftwareBildquelle: http://www.flickr.com/photos/gagilas/3809232008/

WSGI, FastCGI, mod_pythonBildquelle: http://www.flickr.com/photos/torkildr/3462607995/

Architektur

Unicode

Object RelationalMapper

Form

ular

e

Template

FilterTags

Serializer

XML JSON

Applications

View

URLConf

Admin

Valid

ator

en

YAML

Syndication

AtomRSSTe

stin

g

Cac

he

i18n

Mid

dlew

are

Full Stack Framework

PythonDatenbanken

Models

Webserver

Webserver

Webserver

URLConf

Webserver

URLConf Middleware

Webserver

URLConf Middleware

View

Webserver

URLConf Middleware

View

Webserver

URLConf Middleware

View

Webserver

Model (ORM)

URLConf Middleware

View

Webserver

Model (ORM)

URLConf Middleware

View

Webserver

Datenbank

Model (ORM)

URLConf Middleware

View

Webserver

Datenbank

Model (ORM)

URLConf Middleware

View

Webserver

Datenbank

Template

Model (ORM)

URLConf Middleware

View

Webserver

Datenbank

Template

Model (ORM)

URLConf Middleware

View

Webserver

Datenbank

Template

Model (ORM)

URLConf

Tags & Filter

Middleware

View

Webserver

Datenbank

Template

Model (ORM)

URLConf

Tags & Filter

Middleware

from django.db import models

class Musician(models.Model): first_name = models.CharField(max_length=50) last_name = models.CharField(max_length=50) instrument = models.CharField(max_length=100)

class Album(models.Model): artist = models.ForeignKey(Musician) name = models.CharField(max_length=100) release_date = models.DateField() num_stars = models.IntegerField()

Model

URLConf

from django.conf.urls.defaults import *

extra_patterns = patterns('', url(r'reports/(?P<id>\d+)/$', 'credit.views.report', name='credit-reports'), url(r'charge/$', 'credit.views.charge', name='credit-charge'),)

urlpatterns = patterns('', url(r'^$', 'apps.main.views.homepage', name='site-homepage'), (r'^help/', include('apps.help.urls')), (r'^credit/', include(extra_patterns)),)

View

from django.shortcuts import render_to_response, get_object_or_404

from ponyfarm.models import Farm

def farm(request, farm_id): farm = get_object_or_404(Farm, pk=farm_id) return render_to_response('ponyfarm/farm.html', {'farm': farm})

Template<html><head> <title>{% block title %}My Pony Farm{% endblock %}</title></head><body> <h2>My Pony Farm</h2> {% block content %} {% endblock %}</body></html>

{% extends "base.html" %}{% block title %}{{ block.super }} - {{ farm.title }}{% endblock %}{% block content %} <h3>{{ farm.title }}</h3> <p>{{ farm.description|linebreaks }}</a></p> <p><a href="{% url ponyfarm_object_list %}">back to overview</a></p>{% endblock %}

Eingebauter Webserver$ python manage.py runserverValidating models...0 errors found

Django version 1.1.1, using settings 'ponysite.settings'Development server is running at http://127.0.0.1:8000/Quit the server with CONTROL-C.[25/Mar/2010 17:48:50] "GET /admin/ HTTP/1.1" 200 1686[25/Mar/2010 17:49:04] "POST /admin/ HTTP/1.1" 302 0[25/Mar/2010 17:49:04] "GET /admin/ HTTP/1.1" 200 5674[25/Mar/2010 17:49:08] "GET /admin/auth/user/ HTTP/1.1" 200 4788[25/Mar/2010 17:49:14] "GET /admin/ HTTP/1.1" 200 5674[25/Mar/2010 17:49:17] "GET /admin/auth/user/ HTTP/1.1" 200 4788

Admin

Djangoin freier Wildbahn

www.ljworld.com

www.theonion.comBildquelle: http://twitter.com/TheOnion/status/10921296161

www.everyblock.com

disqus.com

www.rapidsms.orgBildquelle: http://www.rapidsms.org/about/take-the-tour/

filmaster.com

trailmapping.com

Djangoin Deutschland

Django-EntwicklerBildquelle: http://djangopeople.net/de/

DeutscherDjango-Verein e.V.• Gegründet im Dezember 2009

• 16 Mitglieder

• Kommunikation der Entwickler und Anwender fördern

• Weiterentwicklung von Django voran treiben

• www.django-de.org

Weiterführende Links

• www.djangoproject.com

• www.djangobook.com/en/2.0

• djangoplugables.com

• www.djangosnippets.org

• www.python.org

• www.diveintopython.org

DjangoCon Europe

Python & DjangoWorkshop

• 17. April 2010

• Python: 9:00 bis 13:00 Uhr

• Django: 14:00 bis 18:00 Uhr

• Im Coworking Space „Le Space“

• Unkostenbeitrag: 10 EUR

• Anmeldung: info@keimlink.de

Lizenz

Dieses Werk ist unter einem Creative Commons Namensnennung-Weitergabe unter gleichen

Bedingungen 3.0 Unported Lizenzvertrag lizenziert. Um die Lizenz anzusehen, gehen Sie bitte zu

http://creativecommons.org/licenses/by-sa/3.0/ oder schicken Sie einen Brief an Creative Commons, 171 Second Street, Suite 300, San Francisco, California

94105, USA.

Django is a registered trademark of the Django Software Foundation.

top related