Django Show

Download Django Show

Post on 14-May-2015

6.058 views

Category:

Technology

0 download

Embed Size (px)

TRANSCRIPT

<ul><li>1.Django Show </li></ul> <p>2. Um pouco sobre mim Formado em Cincia da Computao Entusiasta de Python e Django Colaborador do DjangoBrasil e do PythonBrasil Desenvolvedor na globo.com 3. Django Show no ... Um show de uma boy band Uma apresentao de um indiano cantando barby girl Nem uma demonstrao de magia 4. Welcome to the Django! 5. Arquitetura Model View Template 6. Modelfrom django.db import models from datetime import datetimeclass Link(models.Model):title = models.CharField(max_length = 255)date = models.DateTimeField(default = datetime.now)url = models.URLField(verify_exists = False)description = models.CharField(max_length = 255)def __unicode__(self): return self.description 7. View from django.shortcuts import render_to_response from models import Linkdef index(request): links = Link.objects.all() return render_to_response('index.html',{'links':links}) 8. Template {% extends quot;base.htmlquot; %}{% block content %}{% for link in links %} </p> <p>{{ link.title }} -{{ link.date|date:quot;d/m/Yquot; }} </p> <p> {% endfor %}{% endblock %} 9. Manipulando os dados &gt;&gt;&gt; from mysite.bookmarks.models import * &gt;&gt;&gt; l = Link()&gt;&gt;&gt; l.title = 'Python Brasil' &gt;&gt;&gt; l.description = 'Site da comunidade Python no Brasil' &gt;&gt;&gt; l.url = 'http://www.pythonbrasil.com.br' &gt;&gt;&gt; l.save() &gt;&gt;&gt; l &gt;&gt;&gt; l = Link() &gt;&gt;&gt; l.title = 'Django Brasil' &gt;&gt;&gt; l.description = 'Site da comunidade Django no Brasil' &gt;&gt;&gt; l.url = 'http://www.djangobrasil.org' &gt;&gt;&gt; l.save() &gt;&gt;&gt; 10. Gerao de Formulrios Model x View x Template Model x View (Forms + Metodos) x Templates 11. from django.forms import ModelForm from models import Linkclass LinkForm(ModelForm):class Meta:model = Link 12. Interface de Administrao Model x ModelAdmin 13. from django.contrib import admin from models import Linkadmin.site.register(Link) 14. Middleware views 15. MiddlewareMIDDLEWARE_CLASSES = ( 'django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', ) 16. Algumas middlewares Session Authentication Log Gzip 17. Mitos e verdades Django e monoltico Django no escala O deploy no Django difcil e complicado 18. Django e ZODB desafio ou loucura? =) 19. import ZODB.configclass ZODBConnection(object):def __init__(self): db = ZODB.config.databaseFromURL(zodb_url)connection = db.open() self.root = connection.root()ZODBInstance = ZODBConnection() 20. from djangozodb import ZODBInstanceclass ZODBSession(object):def process_request(self, request):request.zodb = ZODBInstance 21. Outros exemplos Django + SQLAlchemy (tranquil) Django + Storm Django + CouchDb Django + SQLObject Django + Seu ORM Favorito Django + BigTable on Google App Engine 22. Mais um exemplo Django + REST 23. Cache Cache em disco Cache em memria Cache em banco 24. Cache Cache em disco Cache em memria Cache em banco ???? = 25. Deploy Apache = mod_python Apache = mod_wsgi Apache = fast_cgi Lighttpd = fast_cgi Nginx = fast_cgi ... 26. Em todo lugar... Cpython Jython IronPython PyPy ????? 27. Em todo lugar... Cpython Jython IronPython PyPy =) 28. Extra Authentication Backend Signals Django + {{ sua template system }} 29. Duvidas? Andrews Medina andrewsmedina@gmail.com http://www.andrewsmedina.com </p>