Skip to content

Instantly share code, notes, and snippets.

View carvalhochris's full-sized avatar

Christopher Carvalho carvalhochris

View GitHub Profile
@carvalhochris
carvalhochris / django_ninja_from_orm.md
Last active January 2, 2025 07:43
How to use Django Ninja schemas to serialize a queryset before returning a response

Take this example of a view that returns two querysets each nested into its own object

# schemas.py

class CardModelOut(ModelSchema):
    class Meta:
        model = Card
        fields = [
 "id",
@carvalhochris
carvalhochris / token_in_email_out.py
Created August 24, 2025 21:10
Python Decode Auth0 JWT with JWK Endpoint
from django.conf import settings
from django.http import HttpRequest
import requests
from joserfc.jwk import KeySet
from joserfc import jwt
from joserfc.jwt import Token
from requests import Response
from project.types import EmailOrNot, OptionalEmail, OptionalToken