DjangoCon 2015

Utilidades y funcionalidades poco conocidas de Django

Sebastian Vetter  · 


Extracto de la transcripción automática del vídeo realizada por YouTube.

hello thanks for the introduction yeah as Adam just said I'm Sebastian I am currently my main profession is a django web developer I've done some Python academic work I work for a company called modify in Vancouver in Canada which I just moved to about

six seven months ago and if you want to find me online I'm usually found as alva sheet and the slides for this talk are going to be online on speaker deck this is the bitly link i'll have that later on the slides as well but let's find some treasures

what I mean by that is we're all or most of us are familiar with firms and views and all the sort of good things that Django has to offer and the things that we use Django for but they are an old hat for those of us that have worked with it for a long

time as well so I'm trying to talk about a little bit more about what the hidden treasures are and what I mean by that is basically when you look through the code in Django you come across like utility functions and things like that that are implemented

in Django to facilitate all those other features but they might actually be useful in your project or for your use case and you don't have to write and maintain those little pieces of code yourself the first question around that is where do you find that

and the way I found those was mostly through either looking at the Django source code itself because I wanted to try and understand this or that piece of code or something went wrong and I didn't quite understand what I did wrong so I had to dig into the

code to understand it properly class-based view and they're nested nature are a very good example for that and obviously working with smart people that or talking to smart people that told me oh basically this thing that you were doing over here there

is something in Django that already does that and you can just use it and then there was my personal favorite source of information is a funky Bob that I had the pleasure to meet over and over again during my time in mebane but he's like the person to

ask questions on IRC and he's a great resource but generally IRC is a great resource to ask questions and then there is sprinting at conferences and that goes back to like meeting smart people and talking to those people learning what other people do and

picking their brains so what I'll be doing is I'll just pick a few things out that I've been that now I found really useful and point out like how I've used them and what might be a good way of for you to use those one of my personal favorites

probably is the cash property decorator so it is basically just a decorator what it does it's all in the name it's a property on a class the return value gets cached so you don't have to re compute whatever it is inside that function so this is

basically what it looks like you have your class and instead of using the app property decorator there is a cash property decorator provided by Django that cash as the result of the function now this can be useful for things like very compute heavy properties

or a property that you expose that relates to multiple different tables in a database and you have to aggregate data some sort or you're accessing another web api and retrieve data that way so sorry as an example let's take this class of a color object

and we have that object as a hex value and we have this amazing remote API that for any given hex value of a color gives you the name and you expose that as a property which means every time you have that you access that property you'll make a remote call

[ ... ]

Nota: se han omitido las otras 1.799 palabras de la transcripción completa para cumplir con las normas de «uso razonable» de YouTube.