Tag « django »

django , orm , migrations

Changing the primary key of a model in Django

I had to change the primary key of a django model, and I wanted to create a migration for this.

The previous model was using django automatic primary key fields

I firstly changed the model to include the new uuid field, and added the id field (the old primary key …

django , urls , uuid

Using uuids in URLs in a Django app

After adding a regexp for uuids (which are quite hard to regexp for), I discovered that Django offers path converters, making this a piece of cake.

I was using old school re_path paths in my urls.py, but it’s possible to replace them with path, like this:

url_patterns = (
    path …
django , pytest

Profiling and speeding up Django and Pytest

Éloi made a pull request on IHateMoney to speedup the tests, with some great tooling for pytest that I wasn’t aware of: