Skip to content

Instantly share code, notes, and snippets.

View bmispelon's full-sized avatar

Baptiste Mispelon bmispelon

View GitHub Profile
@bmispelon
bmispelon / Django_SC_December2024.csv
Created December 11, 2024 11:14
Django Steering Council candidate statements December 2024
We can make this file beautiful and searchable if this error is corrected: Unclosed quoted field in line 2.
Name,Pronouns,Location,Statement
Andrew Miller,(he/him),"Cambridge, UK","Hi there, for those that haven’t come across me yet, I’m very active on the Discord, joining a couple of years ago, I serve as a moderator and generally helping out. I have also authored a Working Group proposal that is almost ready to go live, pending Board approval. Finally I organise the monthly Django Social in Cambridge.
However perhaps what is most relevant to my nomination for the Steering Council are the blog posts I have written this year. They have been short & snappy where I have prodded and explained different aspects of using Django, the contributing process and other aspects of the community.
I am nominating myself for the Steering Council to ensure that Django has a secure future. Personally I have used Django for the last 12 years and it has been integral to my software engineering career. The last two and half years have been the best in terms of getting involved in the community and has increased my passion for improv
We can make this file beautiful and searchable if this error is corrected: Unclosed quoted field in line 1.
Abigail Gbadago,"Accra, Ghana","Hi,
I am Abigail(Afi), a DSF member who has contributed to the Django Ecosystem for about four years. I have held the following positions in the community:
Leadership council member for Black Python Devs (current)
Open Source Program Manager for Black Python Devs - I am managing 39 of our community members make their first steps in open source (current)
Programs Team member for DjangoCon US 2024
Contributed in organizing Django Girls Zanzibar (2023) ahead of the first DjangoCon Africa, co-organiser of Django Girls in Kwahu-Ghana (2019), and coach at Django Girls Ho-Ghana; 2018, 2024 and Zanzibar (2023)
DjangoCon US Speaker 2023, you can watch my talk here: Strategies for Handling Conflicts and Rollbacks with Django
@bmispelon
bmispelon / backends.py
Last active June 30, 2024 13:10
A Django cache backend to help transition from an old backend to a new one
from django.core.cache import BaseCache, CacheHandler
from django.core.cache.backends.base import DEFAULT_TIMEOUT
from django.core.exceptions import ImproperlyConfigured
class TransitionCache(BaseCache):
"""
A cache backend that helps transitioning from one backend to another.
To use it, set both 'NEW' and 'OLD'as keys in the backend's configuration
@bmispelon
bmispelon / client_list.html
Created June 25, 2024 13:22
Attempt at replicating https://softwarecrafts.co.uk/100-words/day-119 with plain prefetches
<table>
{% for client in clients %}
...
<tr>
...
<td>
<select>
{% for group in client.groups.all %}{# prefetched #}
<option{% if group.pk in user_groups %} selected{% endif %}>{{group}}</option>
{% endfor %}
@bmispelon
bmispelon / months_html.py
Created April 17, 2024 20:37
Get a table of month names in various languages, using Django translation machinery
import django
django.setup()
from django.utils import translation
from django.utils.dates import MONTHS
def monthstr(i, lang):
translation.activate(lang)
return str(MONTHS[i])
@bmispelon
bmispelon / int_to_english.py
Created May 18, 2022 11:05
Convert an integer into english
import sys, unicodedata
def int_to_english(n: int) -> str:
"""
Convert the given integer into english (only works reliably for numbers between 1 and 31).
"""
return unicodedata.name(chr(13279 + n)).split()[-1]
if __name__ == '__main__':
@bmispelon
bmispelon / unicode_poetry.py
Created May 16, 2022 15:18
A poetry generator in 5 lines of python
import random as r, unicodedata
coolwords = [unicodedata.name(chr(119556+i)).split()[-1] for i in range(83)]
for w in r.sample(coolwords, r.randrange(9, 15)):
print(w, end=r.choice(' \n'))
print()
@bmispelon
bmispelon / find_templates.py
Created October 20, 2021 14:55
Exhaustively list all available templates in a Django project
from pathlib import Path
from django import template
def gen_all_templates():
"""
Generate the list of all available templates as tuples of 3 values:
- the template engine
@bmispelon
bmispelon / update.py
Created March 2, 2021 09:53
[Django ORM] Updating a JSONField based on the value of another field
"""
How to update JSONField based on the value of another field.
For example:
class MyModel(models.Model):
name = models.CharField(...)
data = models.JSONField()
How to update the MyModel table to store the `name` field inside the `data`
@bmispelon
bmispelon / checkchoices.py
Last active December 6, 2020 17:39
A Django management command to find model fields where the declared choices doesn't match what's in the database
"""
When a model field defines a `choices` attribute, Django doesn't actually
generate a database constraint for that, which means it's possible to insert
data that doesn't match the choices.
See https://adamj.eu/tech/2020/01/22/djangos-field-choices-dont-constrain-your-data/
This command scans your database to try and find which fields have mismatched
data.
By default it scans all fields of all models of all installed apps, doing one