Install a pip package from a git repo, using a specified git reference:
[Read More]Simple Redirect View for Django
I often find myself replacing an existing MVP based on static html with a Django app, or just needing to preserve some old URL scheme.
This is the code I use to do that:
from django.shortcuts import redirect
def redirect_view(request, redirectable, permanent=True):
return redirect(redirectable)
Which can then be used like this:
from django.urls import path
from . import views
urlpatterns = [
path("old-url/", views.redirect_view, {"redirectable": "new_view"}),
path("some-thing/", views.redirect_view, {"redirectable": "some_thing_new", permanent=False}),
]
Debugging Container Workloads
A helper container
Debugging container workloads can be a challenge sometimes, especially when running them in k8s, behind a reverse proxy or in other, possibly complex, traffic flow scenarios.
[Read More]Register all models with Django admin
Sometimes, mostly when throwing together a quick idea or MVP, it can be useful to just register all models with the admin and leave proper customization for later.
[Read More]Django: CSRF exempt view
Django’s CSRF protection is usually a great thing, but when building (API) endpoints meant to be accessed by scripts/third parties it gets in the way of that.
This is how to disable it:
For a class based view
from django.utils.decorators import method_decorator
from django.views.decorators.csrf import csrf_exempt
@method_decorator(csrf_exempt, name='dispatch')
class MyView(View):
pass
For a function based view
from django.views.decorators.csrf import csrf_exempt
@csrf_exempt
def my_view(request):
pass
Handling signals with Python
ArgoCD Python Client
A simple Python client to interact with ArgoCD.
[Read More]GitLab: User owned projects report
Export a CSV formatted report of projects in user-namespace on a GitLab instance.
This is especially useful if you think about limiting or disabling this feature.
[Read More]Local S3 with MinIO in Django
Python
These days Python is my language of choice for both simple scripts and more complex backend applications, usually in combination with django