dynamic_rest package¶
Submodules¶
dynamic_rest.bases module¶
This module contains base classes for DREST.
dynamic_rest.conf module¶
dynamic_rest.constants module¶
dynamic_rest.datastructures module¶
This module contains custom data-structures.
-
class
dynamic_rest.datastructures.
TreeMap
[source]¶ Bases:
dict
Tree structure implemented with nested dictionaries.
-
get_paths
()[source]¶ Get all paths from the root to the leaves.
For example, given a chain like {‘a’:{‘b’:{‘c’:None}}}, this method would return [[‘a’, ‘b’, ‘c’]].
Returns: A list of lists of paths.
-
insert
(parts, leaf_value, update=False)[source]¶ Add a list of nodes into the tree.
The list will be converted into a TreeMap (chain) and then merged with the current TreeMap.
For example, this method would insert [‘a’,’b’,’c’] as {‘a’:{‘b’:{‘c’:{}}}}.
Parameters: - parts – List of nodes representing a chain.
- leaf_value – Value to insert into the leaf of the chain.
- update – Whether or not to update the leaf with the given value or to replace the value.
Returns: self
-
dynamic_rest.fields module¶
dynamic_rest.filters module¶
dynamic_rest.links module¶
This module contains utilities to support API links.
dynamic_rest.meta module¶
Module containing Django meta helpers.
-
dynamic_rest.meta.
get_model_field
(model, field_name)[source]¶ Return a field given a model and field name.
Parameters: - model – a Django model
- field_name – the name of a field
Returns: A Django field if field_name is a valid field for model, None otherwise.
-
dynamic_rest.meta.
is_field_remote
(model, field_name)[source]¶ Check whether a given model field is a remote field.
A remote field is the inverse of a one-to-many or a many-to-many relationship.
Parameters: - model – a Django model
- field_name – the name of a field
Returns: True if field_name is a remote field, False otherwise.
dynamic_rest.metadata module¶
dynamic_rest.pagination module¶
dynamic_rest.patches module¶
This module contains patches for Django issues.
These patches are meant to be short-lived and are extracted from Django code changes.
-
dynamic_rest.patches.
patch_prefetch_one_level
()[source]¶ This patch address Django bug https://code.djangoproject.com/ticket/24873, which was merged into Django master in commit 025c6553771a09b80563baedb5b8300a8b01312f into django.db.models.query.
The code that follows is identical to the code in the above commit, with all comments stripped out.
dynamic_rest.processors module¶
dynamic_rest.renderers module¶
dynamic_rest.routers module¶
dynamic_rest.serializers module¶
dynamic_rest.tagged module¶
This module contains tagging utilities for DREST data structures.
dynamic_rest.viewsets module¶
Module contents¶
Dynamic REST (or DREST) is an extension of Django REST Framework.
DREST offers the following features on top of the standard DRF kit:
- Linked/embedded/sideloaded relationships
- Field inclusions/exlusions
- Field-based filtering/sorting
- Directory panel for the browsable API
- Optimizations