O'Reilly logo

Django Unleashed by Andrew Pinkham

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

26.3.6 Using Migrations to Learn about Optimization

We could now jump into our views and begin optimizing our webpages there. Before we do, however, I want to draw your attention to our migration files.

By default, when you run tests (when, not if) Django creates a new database based on migrations files. Despite living in memory, this process can be quite time consuming. A fun exercise for learning to optimize code is to take the code in our migrations and attempt to speed them up. This exercise also provides the opportunity for us to use the Q object.

Info

It is possible to disable migrations during tests. If you have a large number of migrations, disabling them for your tests may be advisable.

When we programmed our Tag data migration in ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required