Skip to content

Commit

Permalink
✨Add disable_dynamic_fields kwarg to DynamicFieldsMixin
Browse files Browse the repository at this point in the history
- Closes #121
  • Loading branch information
yezyilomo committed Dec 13, 2019
1 parent 7f59d73 commit 026b802
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion django_restql/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,13 @@ def get_parsed_restql_query_from_req(cls, request):

class DynamicFieldsMixin(RequestQueryParserMixin):
def __init__(self, *args, **kwargs):
# Don't pass 'query', 'fields' and 'exclude' kwargs to the superclass
# Don't pass 'query', 'fields', 'exclude', 'return_pk'
# and 'disable_dynamic_fields' kwargs to the superclass
self.parsed_restql_query = kwargs.pop('query', None)
self.allowed_fields = kwargs.pop('fields', None)
self.excluded_fields = kwargs.pop('exclude', None)
self.return_pk = kwargs.pop('return_pk', False)
self.disable_dynamic_fields = kwargs.pop('disable_dynamic_fields', False)

is_field_kwarg_set = self.allowed_fields is not None
is_exclude_kwarg_set = self.excluded_fields is not None
Expand Down Expand Up @@ -223,6 +225,7 @@ def fields(self):
is_not_a_request_to_process = (
request is None or
request.method != "GET" or
self.disable_dynamic_fields or
not self.has_restql_query_param(request)
)

Expand Down

0 comments on commit 026b802

Please sign in to comment.