Displaying all validation errors in DRF
Django REST framework by default does not give you errors from a custom validate() method if there are also errors from individual serializer fields.
more ...Django REST framework by default does not give you errors from a custom validate() method if there are also errors from individual serializer fields.
more ...If you run a ReST-style web API, It can be a bit tricky to decide which authentication mechanism is right for your scenario. Even more so if you need to support multiple different types of clients. Plain tokens? JWT? Session cookies? OAuth2? What about CORS? Do you neec CSRF protection ...
more ...Django's user model treats usernames case-sensitively by default. This is basically never what you want.
It is quite common these days to treat the e-mail address as the login name. E-mail addresses are case-sensitive according to the relevant standards, but in practice they are not. Users will arbitrarily switch ...
more ...Moving a Django model to another app can be tricky. Here is a quick rundown of the most convenient way I found so far. The idea is to simply rename the database tables, and force Django to consider this the new state of your models. Thanks to Marten Kenbeek who ...
more ...There are situations where you want to reset your Django migrations. Jessamyn Smith has written a nice summary of how to do it properly.
more ...Here's a simplified overview over Django's architecture (ODP format). Just in case anyone finds this useful. I couldn't find a diagram that came with appropriate license information, so I drew one myself. As you can see, I am not much of an artist ;) I am releasing this ...
more ...From time to time, I run into a problem that only occurs in a production-like Django setup (DEBUG off, running under gunicorn, static asset compression in play, and so on).
Debugging such issues on a staging system can be time-consuming. Sometimes, there is no alternative. But often, it's easier ...
more ...Using a pip cache on GitLab CI can speed up your builds considerably (my build time went down from 8 minutes to 3 minutes). Here is how to do it:
# .gitlab-ci.yml
image: python:2
variables:
PIP_CACHE_DIR: "$CI_PROJECT_DIR/pip-cache"
cache:
paths:
- "$CI_PROJECT_DIR/pip-cache"
key: "$CI_PROJECT_ID"
test:
script:
# Make sure you ...
Sometimes, you want to assert that an object was called with some arguments, but the exact value for an argument is computed by some external logic that you do not want your test to depend on. Let's say it is generated by a template, and in this particular case ...
more ...