Question:To test my serializers in django rest framework I use
Model Name.objects.createmethod to create fields. But I can’t create ManyToManyField.
Guess, firstly I need to create objects for first model and for second model otherwise ManyToManyField bound can’t be created. But still can’t define ManyToManyField for test with create method.
Please help me to realize how it should work correctly. I’ve red django documentation, but haven’t got how to solve my issue. Here is my code example:
None, how to define
Thank you in advance.
Answer:I think the command is correct. You can define
ManyToManyusing set and modify using
remove. You can also use just ids of them like the following.
If you have better answer, please add a comment about this, thank you!