background preloader

Django

Facebook Twitter

Django Performance Patterns 1: Measuring Performance. Preface As Django has matured it’s being used for bigger and bigger projects. At the same time it’s also being used by more and more people building relatively simple applications quickly. Everyone’s application is different, but I’d wager the vast majority of these have a range of common performance problems. Performance is often something only larger teams get to spend time really getting to grips with. This is sometimes because smaller projects can’t afford the time, or more often probably that things are thought to be fast enough anyway.

One advantage of using a framework is the sharing of common solutions to common problems that happens as a community forms. I’m going to be pretty opinionated about the stack I’m using when necessary. Measuring Performance In this first part of the series lets take a quick detour to frame everything else. We’ll start out looking at a few tools which are useful when taking a view by view approach to analysing performance. Django Debug Toolbar YSlow. A JavaScript and Web Design/Programming Resource By Matt Snider | Coverage and Mock. This article continues the series on building a continuous deployment environment using Python and Django.

So far we have covered the basics of setting up a Django project and testing it. Today we will discuss how to ensure your tests fully cover the application using the Python mock and coverage tools. Getting ready Coverage is a tool that indicates the lines of code executed when a command runs, such as manage.py test.

To install coverage (version 3.4 was the latest when writing this article), enter your project's context, and run : Mock is a tool that allows developers to specify fake responses for parts of their code. How to do it… Coverage Using coverage is really easy, simply run the test management command through it: You may also output the report in HTML or XML formats: Using coverage this way works, as long as you ensure each file in the project is imported by the tests, because coverage will only report on files that are loaded during the run command.

Using Mock There's more… Scraping - Django REST framework. Re-ordering child nodes in django-MPTT. Intégration continue d'un projet Django. Pdfform.