Properly Defining SerializerMethodFields in DRF

I’m currently implementing a RESTful API with Django Rest Framework (a fantastic framework by the way). I’m mostly depending on the automatic serialization that a ModelSerializer provides. class ReportSerializer(serializers.ModelSerializer): class Meta: model = models.Report fields = (‘id’, ‘name’) But sometimes you need extra fields. In my case I wanted to add a readonly image_url field […]

Read More

Profiling Pytest Tests

If you want to run a profiler over your pytest cases (including underlying code), the easiest way is to run pytest directly using cPython: python -m cProfile -o profile $(which py.test) You can even pass in optional arguments: python -m cProfile -o profile $(which py.test) tests/worker/test_tasks.py -s campaigns This will create a binary file called […]

Read More

First Tests with the Micropython Board

Micropython Micropython (https://micropython.org/) is an implementation of the Python 3 language for microcontrollers. While this might sound like a stupid idea at first (why use a high level garbage collected language on low level hardware?), the creator Damien George has put a great amount of effort into this project. And it’s safe to say that […]

Read More

Scrolling Text with RPLCD

The RPLCD Library Last year when I started playing around with HD44780 based character LCDs on the Raspberry Pi, I did not find any software library for it that I liked. There were some C++ libraries around and also some Python scripts, but they were a bit messy and not as clean and consistent as […]

Read More

Down the Tweet Chain Rabbit Hole

Today I stumbled over an apparently interesting tweet by @aendu: Tweet of aendu/433586683615784960 The link in the tweet points to another tweet: Tweet of madmenna/433585834193715200 And, as you may have guessed, this link points to yet another tweet. After about 20 levels deep I stopped clicking on the links and wrote a Python script instead: […]

Read More