django-planet

Feed: django on roschegel

Recent content in django on roschegel

Blog roschegel
RSS 2.0 Feed django on roschegel
web https://schegel.net/tags/django/
Last Update05.17.2024
Posts3

Simplified Django Tests With Pytest and Pytest FactoryBoy

May 17, 2020 » django on roschegel » [Archived Version]

I’m always trying to find ways to make tests easier to read and extend. I hate working through a really hard feature and having to spend a big amount of time writing tests. Lately, I’ve been bothered by the amount of boilerplate on my test code. So, I decided to do some research and look for alternatives. When testing Django applications, I use a combination of Pytest fixtures and FactoryBoy to write tests that need database records. Pytest Fixtures allow you to abstract the initi…

Read More

Making your Django tests faster

May 9, 2020 » django on roschegel » [Archived Version]

Tests need to be fast. If tests are slow, our development process is affected and we end up spending a considerable amount of time waiting for the results. I will go through some of the techniques that I’ve applied to speed up tests on Django applications. Tips for speeding up test execution 1. Run your tests in parallel If you are running your tests on multi-core hardware, running your tests in parallel is probably the best optimization you can make if you aren’t doing it yet. If you are using…

Read More

Optimizing Django ORM Queries

May 3, 2020 » django on roschegel » [Archived Version]

The Django ORM (Object Relational Mapping) is one of the most powerful features of Django. It enables us to interact with the database using Python code instead of SQL. It has multiple advantages: The database engine is abstracted from us, so it is possible to switch to another database system with ease. It supports migrations: we can easily change our tables by updating our models and Django will automatically generate the migration scripts needed to update the database tables. It supports tr…

Read More