Bugfixes and BeyondJannis LeidelDjango Netherlands MeetupJanuary 12, 2011
1.3, bugfix  release
How many fixes?** until today, January 12th
How many fixes?*    1,330 changed files* until today, January 12th
How many fixes?*    1,330 changed files    85,030 additions* until today, January 12th
How many fixes?*    1,330 changed files    85,030 additions    39,884 deletions* until today, January 12th
What‘s new?
What‘s new? Class-based views
What‘s new? Class-based views Logging
What‘s new? Class-based views Logging Static files
What‘s new? Class-based views Logging Static files Caching
What‘s new? Class-based views Logging Static files Caching Internationalization   and more…
Class-based views
Hello, view!# hello/views.pyfrom django.views.generic import TemplateViewclass HelloView(TemplateView):   template_name = ...
URLconf, ahoy!# hello/urls.pyfrom django.conf.urls.defaults import *from hello.views import HelloViewurlpatterns = pattern...
Other well-knowns
Other well-knowns ListView, DetailView, RedirectView
Other well-knowns ListView, DetailView, RedirectView ArchiveIndexView, YearArchiveView, MonthArchiveView, WeekArchiveView,...
Other well-knowns ListView, DetailView, RedirectView ArchiveIndexView, YearArchiveView, MonthArchiveView, WeekArchiveView,...
Logging
Yup, good ol‘ loggingimport logginglogging.info("Yay!")
Okay, there ismore…
Okay, there ismore… LOGGING setting to configure logging filters and handler, e.g. database handlers
Okay, there ismore… LOGGING setting to configure logging filters and handler, e.g. database handlers Built-in loggers django...
Okay, there ismore… LOGGING setting to configure logging filters and handler, e.g. database handlers Built-in loggers django...
Static files
The notorious life ofthe MEDIA_* settings
The notorious life ofthe MEDIA_* settings Location for user generated files such as FileField and ImageField data
The notorious life ofthe MEDIA_* settings Location for user generated files such as FileField and ImageField data Location ...
STATIC_ROOT = "/var/www/static/"STATIC_URL = "/static/"
Same as templates# hello/urls.pyfrom django.conf.urls.defaults import *from django.contrib.staticfiles.urls import    stati...
Upcoming SlideShare
Loading in...5
×

Bugfixes and Beyond

3,939

Published on

The slides of the talk I gave at the Django Usergroup Berlin.

Published in: Technology, Spiritual
0 Comments
3 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
3,939
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
27
Comments
0
Likes
3
Embeds 0
No embeds

No notes for slide
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • Bugfixes and Beyond

    1. 1. Bugfixes and BeyondJannis LeidelDjango Netherlands MeetupJanuary 12, 2011
    2. 2. 1.3, bugfix release
    3. 3. How many fixes?** until today, January 12th
    4. 4. How many fixes?* 1,330 changed files* until today, January 12th
    5. 5. How many fixes?* 1,330 changed files 85,030 additions* until today, January 12th
    6. 6. How many fixes?* 1,330 changed files 85,030 additions 39,884 deletions* until today, January 12th
    7. 7. What‘s new?
    8. 8. What‘s new? Class-based views
    9. 9. What‘s new? Class-based views Logging
    10. 10. What‘s new? Class-based views Logging Static files
    11. 11. What‘s new? Class-based views Logging Static files Caching
    12. 12. What‘s new? Class-based views Logging Static files Caching Internationalization and more…
    13. 13. Class-based views
    14. 14. Hello, view!# hello/views.pyfrom django.views.generic import TemplateViewclass HelloView(TemplateView): template_name = "hello.html" def get_context_data(self, **kwargs): return { greeted: world, }
    15. 15. URLconf, ahoy!# hello/urls.pyfrom django.conf.urls.defaults import *from hello.views import HelloViewurlpatterns = patterns(, (r^hello/, HelloView.as_view()),)
    16. 16. Other well-knowns
    17. 17. Other well-knowns ListView, DetailView, RedirectView
    18. 18. Other well-knowns ListView, DetailView, RedirectView ArchiveIndexView, YearArchiveView, MonthArchiveView, WeekArchiveView, DayArchiveView, TodayArchiveView, DateDetailView
    19. 19. Other well-knowns ListView, DetailView, RedirectView ArchiveIndexView, YearArchiveView, MonthArchiveView, WeekArchiveView, DayArchiveView, TodayArchiveView, DateDetailView FormView, CreateView, UpdateView, DeleteView
    20. 20. Logging
    21. 21. Yup, good ol‘ loggingimport logginglogging.info("Yay!")
    22. 22. Okay, there ismore…
    23. 23. Okay, there ismore… LOGGING setting to configure logging filters and handler, e.g. database handlers
    24. 24. Okay, there ismore… LOGGING setting to configure logging filters and handler, e.g. database handlers Built-in loggers django, django.request, django.db.backends
    25. 25. Okay, there ismore… LOGGING setting to configure logging filters and handler, e.g. database handlers Built-in loggers django, django.request, django.db.backends Built-in handler AdminEmailHandler, sending to adresses in the ADMINS setting
    26. 26. Static files
    27. 27. The notorious life ofthe MEDIA_* settings
    28. 28. The notorious life ofthe MEDIA_* settings Location for user generated files such as FileField and ImageField data
    29. 29. The notorious life ofthe MEDIA_* settings Location for user generated files such as FileField and ImageField data Location for non-user generated files such as Stylesheets, Images, JavaScript, etc.
    30. 30. STATIC_ROOT = "/var/www/static/"STATIC_URL = "/static/"
    31. 31. Same as templates# hello/urls.pyfrom django.conf.urls.defaults import *from django.contrib.staticfiles.urls import staticfiles_urlpatternsfrom hello.views import HelloViewurlpatterns = patterns(, (r^hello/, HelloView.as_view()),) + staticfiles_urlpatterns()
    32. 32. Finding the files
    33. 33. Finding the files Ships with a few default file finders
    34. 34. Finding the files Ships with a few default file finders App direcotories: <APP>/static
    35. 35. Finding the files Ships with a few default file finders App direcotories: <APP>/static Additional locations: Paths in STATICFILES_DIRS setting
    36. 36. Finding the files Ships with a few default file finders App direcotories: <APP>/static Additional locations: Paths in STATICFILES_DIRS setting Default storage backend (disabled by default)
    37. 37. Deployment
    38. 38. Deployment Use collectstatic management command to collect all files in one location
    39. 39. Deployment Use collectstatic management command to collect all files in one location Uses standard storage API, able to deploy to S3 and other cloud storages*
    40. 40. Deployment Use collectstatic management command to collect all files in one location Uses standard storage API, able to deploy to S3 and other cloud storages* Or, use your own deployment tool
    41. 41. Caching
    42. 42. Multiple backends# settings.pyCACHES = { default: { BACKEND: django.core.cache.backends.db.DatabaseCache, LOCATION: my_cache_table, }, redis: { BACKEND: my_cache.backends.RedisCache, LOCATION: 127.0.0.1:6379, DATABASE: 11, }}# hello/whatever.pyfrom django.core.cache import get_cacheredis = get_cache(redis)print redis.get(greeting)
    43. 43. MOAR features!
    44. 44. MOAR features! Versions
    45. 45. MOAR features! Versions cache.set(greeting, world, version=2)
    46. 46. MOAR features! Versions cache.set(greeting, world, version=2) Prefixes
    47. 47. MOAR features! Versions cache.set(greeting, world, version=2) Prefixes KEY_PREFIX = dutch-edition
    48. 48. MOAR features! Versions cache.set(greeting, world, version=2) Prefixes KEY_PREFIX = dutch-edition Key transformations
    49. 49. MOAR features! Versions cache.set(greeting, world, version=2) Prefixes KEY_PREFIX = dutch-edition Key transformationsdef minor_version_key(key, key_prefix, version):
    50. 50. MOAR features! Versions cache.set(greeting, world, version=2) Prefixes KEY_PREFIX = dutch-edition Key transformationsdef minor_version_key(key, key_prefix, version): if key == "frontpage":
    51. 51. MOAR features! Versions cache.set(greeting, world, version=2) Prefixes KEY_PREFIX = dutch-edition Key transformationsdef minor_version_key(key, key_prefix, version): if key == "frontpage": version = "%s.%s"
    52. 52. MOAR features! Versions cache.set(greeting, world, version=2) Prefixes KEY_PREFIX = dutch-edition Key transformationsdef minor_version_key(key, key_prefix, version): if key == "frontpage": version = "%s.%s" % (version, settings.MINOR_VERSION)
    53. 53. MOAR features! Versions cache.set(greeting, world, version=2) Prefixes KEY_PREFIX = dutch-edition Key transformationsdef minor_version_key(key, key_prefix, version): if key == "frontpage": version = "%s.%s" % (version, settings.MINOR_VERSION) return :.join(
    54. 54. MOAR features! Versions cache.set(greeting, world, version=2) Prefixes KEY_PREFIX = dutch-edition Key transformationsdef minor_version_key(key, key_prefix, version): if key == "frontpage": version = "%s.%s" % (version, settings.MINOR_VERSION) return :.join( [key_prefix, version, str(key)])
    55. 55. Internationalization
    56. 56. Contexts, finally!# hello/views.pyfrom django.utils.translation import pgettext_lazymonth = pgettext_lazy("month name", "May")# hello/locale/de/LC_MESSAGES/django.pomsgctxt "month name"msgid "May"msgstr "Mai"
    57. 57. Leave a comment# hello/views.pyfrom django.utils.translation import ugettext_lazyclass HelloView(TemplateView): template_name = "hello.html" def get_context_data(self, **kwargs): # Translators: The people you greet greeted = ugettext_lazy("world") return { greeted: greeted, }
    58. 58. Leave a comment# hello/templates/base.html{% comment %}Translators: Remember to translate thiscorrectly, dammit!{% endcomment %}{% blocktrans %} Hello, world!{% endblocktrans %}# hello/locale/de/LC_MESSAGES/django.po#. TRANSLATORS: Remember to translate thiscorrectly, dammit!msgid "Hello, world!"msgstr "Hallo Welt!"
    59. 59. More information 1.3 release notes http://django.me/releases-1.3
    60. 60. Questions? @jezdez
    1. A particular slide catching your eye?

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

    ×