Template tag - list punctuation for a list of items
Djangosnippets
by shapiromatron
3M ago
If you have multiple items in a list and want them to be displayed as human readable list of items, this will add the proper punctuation to generate the text. You'll need to provide a conjugation to the end of the list like "or" or "and"; it defaults to "or ..read more
Visit website
JSONRequestMiddleware adds a .json() method to your HttpRequests
Djangosnippets
by cdcarter
3M ago
add JSONRequestMiddleware to your enabled middleware in Django settings. Now, in your view functions, you can call request.json() to get a parsed json body! json is consumed lazily, and cached ..read more
Visit website
Serializer factory with Django Rest Framework
Djangosnippets
by julio
11M ago
Creates a model serializer class on the fly, just taking the model (class) as its argument. My use case: When importing data from spreadsheets, the DRF serializers are an easy way to create model instances from a dictionary. This function saves me from creating a custom serializer each time I ..read more
Visit website
Image compression before saving the new model / work with JPG, PNG
Djangosnippets
by Schleidens
1y ago
Don't forget to replace "self.image" by your image field name from your model ex ( self.cover ) replace Product by your model name works pretty well ..read more
Visit website
Help text hyperlinks
Djangosnippets
by sa2812
1y ago
Sometimes a plain-text help-text isn't sufficient, and it's handy to be able to add links to pages, documentation or external websites. This javascript snippet can be added to your page, in combination with adding a class to your help text in your template. This assumes you're using jQuery on your ..read more
Visit website
Django Collapsed Stacked Inlines
Djangosnippets
by applecat
1y ago
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 ..read more
Visit website
Stuff
Djangosnippets
by NixonDash
1y ago
Stuff ..read more
Visit website
Add custom fields to the built-in Group model
Djangosnippets
by jmoppel
1y ago
Add fields and extend Django's built-in Group model using a OneToOneField (i.e. a profile model). In this example, we add a UUIDField. Whenever a new group is created, we automatically (via signals) create a corresponding Role record referencing the newly created group. Whenever a Group is deleted, the corresponding ..read more
Visit website
Month / Year SelectDateWidget based on django SelectDateWidget
Djangosnippets
by pierreben
1y ago
A more simple version of https://djangosnippets.org/snippets/1688/, inheriting from SelectDateWidget, overriding only the necessarily. Usage example: In models.py: from django.db import models from django.utils.translation import gettext_lazy as _ class MyModel(models.Model): start = models.DateField( _("Start date"), ) end = models.DateField( _("End date"), ) class Meta: verbose_name = _("My model") In ..read more
Visit website
Python Django CRUD Example Tutorial
Djangosnippets
by tuts_station
1y ago
Hey Friends, In this quick example, let's see django tutorial & crud example with mysql and bootstrap. step by step explain django crud operations with mysql backend. step by step explain django crud operations with mysql bootstrap. let’s discuss about django crud operations with mysql database. Read more... https://tuts-station.com/python-django-crud-example-tutorial.html ..read more
Visit website

Follow Djangosnippets on FeedSpot

Continue with Google
Continue with Apple
OR