Answer the question
In order to leave comments, you need to log in
How to write a condition that depends on the result of a function?
How to write an if condition correctly, depending on the result of executing the filter_by_type function ?
def filter_by_type(self, request, queryset, social_networks):
type = request.query_params.get('type', None)
if type is None:
return queryset
social_network_type = social_networks.get(type.upper(), None)
if social_network_type is not None:
queryset = queryset.filter(content_type=social_network_type.pk)
return queryset
if social_network_type = youtube:
pass
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question