Replies: 1 comment
-
|
i think you should check the models well and set the input of interval. also you could try viewsets with hyperlinkedModel serializer and see if the CRUD operations are working properly |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Summary:
Use drf ModelSerializer component to serialize PeriodicTask and set depth=1,create data report error django.core.exceptions.ValidationError: {'interval': ['One of clocked, interval, crontab, or solar must be set.']}
Exact steps to reproduce the issue:
PeriodicTaskSerializerby DRF SerializerPeriodicTaskViewby DRF APIView,It accepts http post requests and can create tasks{ "name": "test create task", "task": "common.tasks.task_test", "interval": 1, "args": "[]", "kwargs": "{}", "queue": "", "priority": 1, "start_time": "2020-07-04 18:00:00", "one_off": "False", "enabled": "True", "description": "create task by drf" }Detailed information
In the request parameters, I set the
interva=1, but afterserializer.is_valid(), there is no such parameter in theserializer.data, Cause an exception{'interval': ['One of clocked, interval, crontab, or solar must be set.']}to be thrown,If I didn’t set the
depthin thePeriodicTaskSerializer, everything works fineBeta Was this translation helpful? Give feedback.
All reactions