Here's how to find the 10 closest locations to a point for a model that has latitude and longitude columns, if you're not using GeoDjango.
This runs a brute force distance calculation against every row, so it should only be used on smaller tables - probably less than 100,000 rows.
For larger tables you should use GeoDjango instead.
See also [my TIL](https://til.simonwillison.net/postgresql/closest-locations-to-a-point) about this.
A minimally invasive Select widget that looks and acts like a disabled select input, but still submits with the form. It works by rendering the form as disabled, and supplements it's output with a hidden input field with the same name and value.
Tested in Django 3.0, probably works in Django 1.11+
Third party services (e.g. Stripe) optionally sign webhook events to verify it is them sending events. If the third party you use does not provide an SDK or official library for verifying signatures, you can manually verify the signature with this snippet.
Based on https://djangosnippets.org/snippets/2020/ and https://stackoverflow.com/questions/5146539/streaming-a-csv-file-in-django
Can be used on really large querysets.
Read the image url as base64 in django, this snippet usefull if you using the `django-easy-pdf` to solve this issue https://github.com/nigma/django-easy-pdf/issues/53
Usage example:
```
<img src="{{ profile.photo.url|read_image_as_base64 }}">
```
As you can see, if you using django-rest-framework, you will found many different response format. This middleware to solve all of these problems with Standard API Response.
All HTTP Response status stored into json response, not in HTTP Status (because mobile application, like android can't fetch the response body when HTTP Status >= 400).
I separate this in two files, like this:
export_excel.py and actions.py
I tried to treat all possible forms of information that may appear in admin, such as properties, functions and normal fields, always getting the column name verbose_name or short_description depending on the case.