Log the time taken to execute each DB query
Use this snippet to log the time taken to execute a specific DB query.
- django
- db
- logging
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 :)
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.
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.
let say the user chooses the name "Elsa Frozen" now his slug would be "Elsa-Frozen-5" it means 4 other people have used the same header now he can go to url: "your website.com/Elsa-Frozen-4" to see other people's Post
2955 snippets posted so far.