Django package with useful utility classes
Project description
Django Utilitas
Django Utilitas is a library that contains many ready-to-use utility classes so that you can just focus on the business logic of your API.
Utilitas itself is built upon many other great Django packages such as drf-ff, drf-yasg and the Django REST Framework itself.
Feature summary
Here is a summarized version of Utilitas' features:
- pagination
- sorting
- filtering (searching)
- swagger API support
- nested read serializers
- limiting the response' field
Installation
pip install django-utilitas
Documentation
Docs are still in progress. I have assignments to do :(
Setting up a simple CRUD endpoint
Utilitas provides BaseListView
, BaseDetails
and BaseSearchView
which are a more sophisticated version of DRF's default views.
With them, you can set up a powerful API with about 9 lines of codes.
# views.py
class AccountListView(BaseListView):
name = "Account list view" # optional
model = Account # subclass of BaseModel
serializer = AccountSerializer # subclass of BaseModelSerializer
class AccountDetailsView(BaseDetailsView):
name = "Account details view"
model = Account
serializer = AccountSerializer
class AccountSearchView(BaseSearchView):
name = "Account search view"
model = Account
serializer = AccountSerializer
Then, setup the urls like this. Please note that the argument must be named obj_id
.
#urls.py
urlpatterns = [
path("accounts/", views.AccountListView.as_view(), name="account-list"),
path("accounts/<int:obj_id>", views.AccountDetailsView.as_view(), name="account-details"),
path("accounts/search", views.AccountSearchView.as_view(), name="account-search"),
]
Then, when you go to your swagger endpoint, you should be able to see something like this:
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for django_utilitas-1.1.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1d6a849d018e13421b521a58b57697a6ff08799c9c3427fb4756087b59cc3f87 |
|
MD5 | 42c27420778ebdeac1945adab50edd79 |
|
BLAKE2b-256 | 6f05de48dd6ff37e4fd76799126f157e80256b3d8343e978c63ec08a53038ac1 |