django 101                   Todas os conceitos e dicas que você queria saber e o                           seu tutorial c...
Filipe A. Ximenes                            filipeximenes@gmail.com                            traineeworld.com.br/cv/xime...
Real World Django                                TalksSunday, December 16, 12
Renato Oliveira                          Filipe XimenesSunday, December 16, 12
django in a nutshell                   • Django is a high-level Python Web                          framework that encoura...
MVCSunday, December 16, 12
Arquitetura MVC                   • Model                   • View                   • ControllerSunday, December 16, 12
Model                   • modelagem dos dados                   • persistência                   • responsável pela manute...
Controller                   • centro de controle.                   • prepara os dados para serem dispostosSunday, Decemb...
View                   • como os dados são dispostos                   • HTMLSunday, December 16, 12
View                   • A view requests from the model the                          information that it needs to generate...
View                   • the “view” describes the data that gets                          presented to the user. It’s not ...
MVCSunday, December 16, 12
MTVSunday, December 16, 12
Arquitetura MTV                   • Model                   • View                   • TemplateSunday, December 16, 12
Model                   • modelagem dos dados                   • persistência                   • responsável pela manute...
View                   • centro de controle.                   • prepara os dados para serem dispostosSunday, December 16,...
Template                   • como os dados são dispostos                   • HTMLSunday, December 16, 12
Project vs. AppsSunday, December 16, 12
Apps                   • micro instâncias da arquitetura MTV                   • separar funcionalidades o máximo possível...
Project                   • coleção de appsSunday, December 16, 12
Herança de TemplateSunday, December 16, 12
• defina base.html                   • defina blocos                   • extenda base.html e sobrescreva os blocosSunday, De...
Exemplo  <html>     <head>       <title>{% block titulo %}p1{% endblock %} - Exemplo</title>     </head>     <body>       ...
pagina 2   {% extends “base.html” %}   {% block titulo %}p2{% endblock %}   {% block texto %}texto da p2{% endblock %}Sund...
Generic Views                   •      django.views.generic.simple.direct_to_template                          •   (r^minh...
Shortcuts                   • render_to_response                   • redirect                   • get_object_or_404Sunday,...
URL ReverseSunday, December 16, 12
Em urls.py:             from mysite import views             urlpatterns = patterns(,                (r^sobre/$, views.abo...
No seu html:             .             .             .             <a href=”{% url about %}”>Sobre</a>             .      ...
No seu .py:             from django.core.urlresolvers import reverse             from django.http import HttpResponseRedir...
Migrações                   • O que é?                   • South                   • http://south.aeracode.org/Sunday, Dec...
TestesSunday, December 16, 12
Dúvidas?                                        filipeximenes@gmail.com                                 traineeworld.com.br...
Upcoming SlideShare
Loading in...5
×

Django 101

3,105

Published on

Alguns conceitos e dicas que você queria saber e o seu tutorial copy-paste não te falou!

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
3,105
On Slideshare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
5
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Django 101

  1. 1. django 101 Todas os conceitos e dicas que você queria saber e o seu tutorial copy-paste não te falou!Sunday, December 16, 12
  2. 2. Filipe A. Ximenes filipeximenes@gmail.com traineeworld.com.br/cv/ximenes filipeaximenes filipeximenesSunday, December 16, 12
  3. 3. Real World Django TalksSunday, December 16, 12
  4. 4. Renato Oliveira Filipe XimenesSunday, December 16, 12
  5. 5. django in a nutshell • Django is a high-level Python Web framework that encourages rapid development and clean, pragmatic design. • The Web framework for perfectionists with deadlines.Sunday, December 16, 12
  6. 6. MVCSunday, December 16, 12
  7. 7. Arquitetura MVC • Model • View • ControllerSunday, December 16, 12
  8. 8. Model • modelagem dos dados • persistência • responsável pela manutenção dos dados • diretamente relacionado com o banco de dadosSunday, December 16, 12
  9. 9. Controller • centro de controle. • prepara os dados para serem dispostosSunday, December 16, 12
  10. 10. View • como os dados são dispostos • HTMLSunday, December 16, 12
  11. 11. View • A view requests from the model the information that it needs to generate an output representation. (fonte: wikipedia)Sunday, December 16, 12
  12. 12. View • the “view” describes the data that gets presented to the user. It’s not necessarily how the data looks, but which data is presented. The view describes which data you see, not how you see it. It’s a subtle distinction. (fonte: djangoproject.org)Sunday, December 16, 12
  13. 13. MVCSunday, December 16, 12
  14. 14. MTVSunday, December 16, 12
  15. 15. Arquitetura MTV • Model • View • TemplateSunday, December 16, 12
  16. 16. Model • modelagem dos dados • persistência • responsável pela manutenção dos dados • diretamente relacionado com o banco de dadosSunday, December 16, 12
  17. 17. View • centro de controle. • prepara os dados para serem dispostosSunday, December 16, 12
  18. 18. Template • como os dados são dispostos • HTMLSunday, December 16, 12
  19. 19. Project vs. AppsSunday, December 16, 12
  20. 20. Apps • micro instâncias da arquitetura MTV • separar funcionalidades o máximo possível • crie apps genéricos e distribua!Sunday, December 16, 12
  21. 21. Project • coleção de appsSunday, December 16, 12
  22. 22. Herança de TemplateSunday, December 16, 12
  23. 23. • defina base.html • defina blocos • extenda base.html e sobrescreva os blocosSunday, December 16, 12
  24. 24. Exemplo <html> <head> <title>{% block titulo %}p1{% endblock %} - Exemplo</title> </head> <body> <h1>{% block texto %}Hello World{% endblock %}</h1> </body> </html>Sunday, December 16, 12
  25. 25. pagina 2 {% extends “base.html” %} {% block titulo %}p2{% endblock %} {% block texto %}texto da p2{% endblock %}Sunday, December 16, 12
  26. 26. Generic Views • django.views.generic.simple.direct_to_template • (r^minha_url/$, direct_to_template, {template: meu_template.html}), • django.views.generic.simple.redirect_to • (^foo/(?P<id>d+)/$, redirect_to, {url: /bar/%(id)s/}),Sunday, December 16, 12
  27. 27. Shortcuts • render_to_response • redirect • get_object_or_404Sunday, December 16, 12
  28. 28. URL ReverseSunday, December 16, 12
  29. 29. Em urls.py: from mysite import views urlpatterns = patterns(, (r^sobre/$, views.about, name=”about”), )Sunday, December 16, 12
  30. 30. No seu html: . . . <a href=”{% url about %}”>Sobre</a> . . .Sunday, December 16, 12
  31. 31. No seu .py: from django.core.urlresolvers import reverse from django.http import HttpResponseRedirect def about(request): return HttpResponseRedirect(reverse(‘about’))Sunday, December 16, 12
  32. 32. Migrações • O que é? • South • http://south.aeracode.org/Sunday, December 16, 12
  33. 33. TestesSunday, December 16, 12
  34. 34. Dúvidas? filipeximenes@gmail.com traineeworld.com.br/cv/ximenes filipeaximenes filipeximenesSunday, December 16, 12
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×