DjangoCon 2015

Mejorando el rendimiento de la parte de administración de las aplicaciones Django

Jacinda Shelly  · 




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

hello um thank you he said my name is Jason de Chelly this is my second time speaking at django con I'm very excited to be here hope you guys have all been having a great time so far i've been using django for a little over four years I've given

a couple of tutorials on the admin love reading and rowing I haven't had time to well much recently and I found in the tutorials that I gave that performance improvements were always a topic of interest and in particular there were a few really easy things

to miss and a few really easy things to change particularly around the list view that people always seem to find interesting so I decided to develop a talk around the basic progression is this you just started using the admin you're relatively new to django

and people have been telling you it's this killer feature first you feel like this i am a god I only wrote one line of code and I have this whole web page now people start using it they start asking you to make feature changes it's really easy you

change one line of code and they have what they want you say they say can you show this column absolutely can you order by this column absolutely all of these tiny little changes that are normally somewhat difficult if you're doing them by hand and Django

has provided all of this to you for free but then there's always a but thin you haven't changed any code but all of a sudden your users start talking to you about how this page seems to be loading really really slowly your database has grown so you

might suspect that it's something to do with queries but you're not really sure you're you're new to django you're not really sure how to figure out what's going on here and now you're thinking oh I'm gonna have to scrap the

admin and it's going to be a month or two months or three months of work to rebuild all of this functionality from scratch and you're starting to tell your team lead or your client or your boss how much time this is going to cost and how many features

you're going to have to put off doing so you can rebuild the admin and they're like no no so what do we do in this talk we're going to go through by example exactly this case and we're going to use a debug tool that is very common very very

commonly used in the Django ecosystem and then if you haven't heard about it yet this talk is probably worth it for just telling you about jingo debug tool are the example that we're going to be using is a library in this library we have users we have

authors and we have books people can check out books and that is represented by the loan books module which is a mini to mini relationship between a book and a user so you can see this here down towards the bottom we have our books relationship which is many

to many for our library user everything else is basically just default user fields we have an author model which is incredibly simple we just have the first name and the last name of the author we have a book model which has a mini to mini relationship with

authors because many books can be you know a book can have many authors and an author can have many books we also keep some ancillary information that's useful to a library like the title and how much we would charge you every day if you returned your

book late finally we have the actual through model so when you have a loaned book you have a relationship between the patron who check the book out the book itself when it's due whether their fines have been paid or not how many times has been renewed

and things like that the original code for this has more comments in it but they basically just say what I told you right here so I removed them so that I can make the slides bigger next django debug tool bar it's on github the installation is very simple

just add it to installed apps for a local development so if you're using run server typically all you have to do is add this to installed apps and you get this nice bar sidebar that when you click on each of the fields will tell you additional information

so you can see how long it's taking for the page to load what your settings are what we'll be concentrating on is how many queries you're running but some other useful things in particular like templates if you've ever had a case where your

template isn't loading and you're not sure what directory is being looked at this will give you that information if you click on that kind of sub field a quick tip if your local development environment is a virtual machine there's an internal ip's

[ ... ]

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