Login

Snippets by jackton1

Snippet List

DRF - Optimizing ModelViewSet queries

Using Django REST Framework for Model views there is always the issue of making duplicated queries without either prefetching the objects that will be accessed using the serializer and as such will lead to large number of queries being made to the database. This will help in optimizing the queryset used for the viewset by accessing the `_meta.fields` property of the serializer.

  • django
  • rest
  • rest-api
  • django-rest-framework
Read More

Support disabling options in a select widget

Provide the ability to disable a select option with Django2. This can be done during the widget initialization (i.e when the widget field is created) or during form initialization. This will disable the select option based on a context or by specifying the values that should be disabled.

  • widgets
  • django-forms
Read More

jackton1 has posted 2 snippets.