Académique Documents
Professionnel Documents
Culture Documents
Bildquelle: http://en.wikipedia.org/wiki/File:Django_Reinhardt_%28Gottlieb_07301%29.jpg
Was ist Django?
• 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
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
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.
Objektorientierte Sprache
Große
Standardbibliothek
Bildquelle: http://www.flickr.com/photos/jhoweaa/327651705/
Unit Testing
Bildquelle: http://www.flickr.com/photos/sidelong/246816211/
Alle Logos und Warenzeichen auf dieser Seite sind Eigentum der jeweiligen Besitzer und Lizenzhalter.
Gute Werkzeuge
für Programmierer
Bildquelle: http://www.flickr.com/photos/philentropist/176054470/
Freie Software
Bildquelle: http://www.flickr.com/photos/gagilas/3809232008/
FastCGI
WSGI
Bildquelle: http://www.flickr.com/photos/torkildr/3462607995/
Architektur
Full Stack Framework
Full Stack Framework
Python
Full Stack Framework
Datenbanken Python
Full Stack Framework
Unicode
Datenbanken Python
Full Stack Framework
Models
Unicode
Datenbanken Python
Full Stack Framework
Object Relational
Mapper
Models
Unicode
Datenbanken Python
Full Stack Framework
Object Relational
Mapper
Models Applications
Unicode
Datenbanken Python
Full Stack Framework
Object Relational
Mapper
Unicode
Datenbanken Python
Full Stack Framework
Object Relational
Mapper URLConf
Unicode
Datenbanken Python
Full Stack Framework
View
Object Relational
Mapper URLConf
Unicode
Datenbanken Python
Full Stack Framework
Template
View
Object Relational
Mapper URLConf
Unicode
Datenbanken Python
Full Stack Framework
Tags
Template
View
Object Relational
Mapper URLConf
Unicode
Datenbanken Python
Full Stack Framework
Tags Filter
Template
View
Object Relational
Mapper URLConf
Unicode
Datenbanken Python
Full Stack Framework
Tags Filter
Template Serializer
View
Object Relational
Mapper URLConf
Unicode
Datenbanken Python
Full Stack Framework
Tags Filter XML
Template Serializer
View
Object Relational
Mapper URLConf
Unicode
Datenbanken Python
Full Stack Framework
Tags Filter XML JSON
Template Serializer
View
Object Relational
Mapper URLConf
Unicode
Datenbanken Python
Full Stack Framework
Tags Filter XML JSON YAML
Template Serializer
View
Object Relational
Mapper URLConf
Unicode
Datenbanken Python
Full Stack Framework
Tags Filter XML JSON YAML
View
Object Relational
Mapper URLConf
Unicode
Datenbanken Python
Full Stack Framework
Tags Filter XML JSON YAML RSS
View
Object Relational
Mapper URLConf
Unicode
Datenbanken Python
Full Stack Framework
Tags Filter XML JSON YAML RSS Atom
View
Object Relational
Mapper URLConf
Unicode
Datenbanken Python
Full Stack Framework
Tags Filter XML JSON YAML RSS Atom
Formulare
Template Serializer Syndication
View
Object Relational
Mapper URLConf
Unicode
Datenbanken Python
Full Stack Framework
Tags Filter XML JSON YAML RSS Atom
Validatoren
Formulare
Template Serializer Syndication
View
Object Relational
Mapper URLConf
Unicode
Datenbanken Python
Full Stack Framework
Tags Filter XML JSON YAML RSS Atom
Testing
Validatoren
Formulare
Template Serializer Syndication
View
Object Relational
Mapper URLConf
Unicode
Datenbanken Python
Full Stack Framework
Tags Filter XML JSON YAML RSS Atom
Testing
Cache
Validatoren
Formulare
Template Serializer Syndication
View
Object Relational
Mapper URLConf
Unicode
Datenbanken Python
Full Stack Framework
Tags Filter XML JSON YAML RSS Atom
Testing
Cache
i18n
Validatoren
Formulare
Template Serializer Syndication
View
Object Relational
Mapper URLConf
Unicode
Datenbanken Python
Full Stack Framework
Middleware
Validatoren
Formulare
Template Serializer Syndication
View
Object Relational
Mapper URLConf
Unicode
Datenbanken Python
Webserver
Webserver
Webserver
URLConf
Webserver
URLConf Middleware
Webserver
URLConf Middleware
Webserver
URLConf Middleware
View
Webserver
URLConf Middleware
View
Webserver
URLConf Middleware
View
Model (ORM)
Webserver
URLConf Middleware
View
Model (ORM)
Webserver
URLConf Middleware
View
Model (ORM)
Datenbank
Webserver
URLConf Middleware
View
Model (ORM)
Datenbank
Webserver
URLConf Middleware
View
Template
Model (ORM)
Datenbank
Webserver
URLConf Middleware
View
Template
Model (ORM)
Datenbank
Webserver
URLConf Middleware
View
Template
Model (ORM)
Datenbank
Webserver
URLConf Middleware
View
Template
Model (ORM)
Datenbank
$ django-admin.py startproject project
$ tree project/
project/
|-- __init__.py
|-- manage.py
Projekt
|-- settings.py
`-- urls.py
$ cd project
$ tree
.
|-- __init__.py
|-- manage.py
|-- ponyfarm
| |-- __init__.py
| |-- models.py
| |-- tests.py
| `-- views.py
|-- settings.py
`-- urls.py
project/ponyfarm/models.py
from django.db import models
from django.contrib.auth.models import User
class Farm(models.Model):
title = models.CharField(max_length=100)
description = models.TextField(blank=True)
class Meta:
pass
@models.permalink
def get_absolute_url(self):
Model
def __unicode__(self):
return self.title
class Pony(models.Model):
title = models.CharField(max_length=100)
slug = models.SlugField(unique=True)
birthday = models.DateField()
farm = models.ManyToManyField(Farm)
user = models.ForeignKey(User)
class Meta:
pass
def farm_list(self):
return ', '.join([farm.title for farm in self.farm.all()])
farm_list.short_description = u'List of farms'
@models.permalink
def get_absolute_url(self):
return ('ponyfarm_object_detail', (), {'slug': self.slug})
def __unicode__(self):
return self.title
project/urls.py
from django.conf.urls.defaults import patterns, include, url
urlpatterns = patterns('',
(r'^admin/', include(admin.site.urls)),
URLConf
(r'^', include('ponyfarm.urls'))
)
project/ponyfarm/urls.py
from django.conf.urls.defaults import patterns, include, url
urlpatterns = patterns('ponyfarm.views',
(r'^farm/(?P<farm_id>[\d]+)/$', 'farm')
)
urlpatterns += patterns('django.views.generic.list_detail',
url(r'^pony/(?P<slug>[-\w]+)/$', 'object_detail', pony_info_dict,
'ponyfarm_object_detail'),
url(r'^$', 'object_list', pony_info_dict, 'ponyfarm_object_list')
)
project/ponyfarm/views.py
View
project/ponyfarm/templates/ponyfarm/farm.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_edit_farm farm_id=farm.id %}">edit</a></p>
<p><a href="{% url ponyfarm_object_list %}">back to overview</a></p>
{% endblock %}
project/ponyfarm/admin.py
from django.contrib import admin
from ponyfarm.models import Farm, Pony
Admin
class FarmAdmin(admin.ModelAdmin):
pass
class PonyAdmin(admin.ModelAdmin):
prepopulated_fields = {'slug': ['title']}
date_hierarchy = 'birthday'
list_display = ('title', 'birthday', 'farm_list')
list_filter = ('farm',)
search_fields = ('title',)
admin.site.register(Farm, FarmAdmin)
admin.site.register(Pony, PonyAdmin)
Admin
Eingebauter Webserver
$ python manage.py runserver
Validating models...
0 errors found
• National Geographic
• Discovery Channel
• Instagram
• Mozilla Add-ons
• FreeNAS
Django
in Deutschland
Django-Entwickler
Bildquelle: http://djangopeople.net/de/
Deutscher
Django-Verein e.V.
• Gegründet im Dezember 2009
• 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
• www.django-workshop.de
• www.djangopackages.com
• www.djangosnippets.org
• www.python.org
• www.diveintopython.org
• learnpythonthehardway.org
djangocon.eu
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.