"Magic Link" Management Command
Django Management Command to print a "Magic Link" for one-click log-in. This is nice for people who project switch or don't want to remember passwords.
- authentication
- magic
- management
- command
Django Management Command to print a "Magic Link" for one-click log-in. This is nice for people who project switch or don't want to remember passwords.
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.
Use this snippet to log the time taken to execute a specific DB query.
..
Sometimes you need to see the json representation of an object, here is how I do it :)
A simple jQuery javascript that collapses all stacked inline rows for better handling of large inline fieldsets. It also adds "Show"/"Hide"-buttons for showing/hiding each row, which could be customized and styled using css. **Usage (see below for example):** Include the javascript on your admin page, together with jQuery, and it'll automatically affect all stacked inlines. **Works with** Django 3.1.4 (Might work with other versions with or without adjustments, but not tested) **Use example:** *admin.py:* class DateInline(admin.StackedInline): model = Date extra = 10 class EventAdmin(admin.ModelAdmin): inlines = [DateInline] class Media: js = ['js/collapsed-stacked-inlines.js'] admin.site.register(Event, EventAdmin)
Automatically setup raw_id_fields ForeignKey & OneToOneField
Getting started with crispy forms
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.
This example below to setup default language code as `id` (Indonesian).
added template tag `{% load country2flag %}` and add `{% flagcss%}` to the html header tag usage: `{{ flag_code_string|country }}`
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 }}"> ```
Django zip longest templatetags to handle more than 3 arguments.
3110 snippets posted so far.