• Trends
  • Topics
  • Nodes
Search for keywords, #hashtags, $sites, add a dash to exclude, e.g. -$theonion.com

From danwald.me

Django's post_save doesn't always

0 1

Django’s post_save methods allow execution of custom code on an insert or update of a record after the save method is called. The serialized object propagates through the signal handlers as the instance parameter which is eventually committed to the ...

on Thu, 4AM

From danwald.me

CONCAT to update db text field

0 0

I needed to collect messages from different processes which was triggered by a record insertion. To keep things simple and denormalized, this stack overflow gem allows for that. from django.db import models class DBModel(models.Model): @classmet...

on Oct 30

From danwald.me

http_referer is not accurate

0 0

The Referer http header (actually a misspelling of referrer) identifies the address of the webpage from which the resources has been requested. I wanted to add this context to an API request fired from that page. When making the request, the value on...

on Sep 28

From danwald.me

Python's all docs are misleading

0 0

Going by the documentation for all, one would think all iterables will early return. The following code will throw an AttributeError on the last item of the list iteratable. def bad_all(o: object, att: str, l: list): if all([o is not None, getat...

on Sep 21

From danwald.me

Shorten pytest's test names

0 1

I noticed that the unittest pipeline was failing. I opened up the logs and saw a wall of text that took about 20 pages to scroll through to see what was failing. It turned out to be an Assert failure where the input wasn't raising an exception. The p...

on Sep 5

From danwald.me

Don't mutate your paginated Queryset

0 0

Django's Paginator works to batch your query items into pages. Under the hood it uses lazy slicing which is accomplished in sql by offset and limit. Warning altering the data affects the limit/offset of proceeding paginated pages data ...

on Aug 3

From danwald.me

Z-Scores in anomaly detection FTW

0 0

Before Slack moved to release bot they used to have human deployment commanders work in 2 hour shifts to walk through deployment steps and monitor metrics for anomalies. This was their CI/CD. The main reasons why people follow CD is to manage risk wi...

on Jul 29

From danwald.me

Filter PII

0 0

Python Logging is a centralized place to filter out sensitive Personally Identifiable Information. The flow chart shows how a LogRecord propagates through the logging frameworks' layers. We can leverage the Filter layer (over the formatter) to redact...

on Jul 17

From danwald.me

Django soft delete Model using Managers

0 0

Below is the soft delete model you can inherit from. It uses an active field which on delete, it will only set to False and not actually delete the records from the overriden delete method. There is a provision available to actually delete records. I...

on Jun 26

From danwald.me

AWS Summit Dubai '24: Notes

0 0

I attended the AWS summit at the Dubai World Trade center's Sheikh Saeed Halls May 29th 2024. Here are some of the notes of the sessions that I was able to attend from over 30+ going on throughout the day. AWS Bedrock is a managed solution using comm...

on Jun 11

From danwald.me

Prod DB CPU spike via testcode

0 0

Our test code APIs for our End-to-End tests can't be accessed in production There was a release that added more unitests before the spike. Looking at the PR with thought nothing of it. What we later found out was that it resulted in 100% CPU utiliza...

on Dec 12