Hi Guys,

I have a m2m relationship (Question - Category) validation issue that I 
have solved but I am not sure if there is a better way or if I am missing 
some info from the docs. I have a form that posts a question that has a 
multi select with existing categories. When I come to save the question in 
QuestionSerializer my validate_category in CategorySerializer which checks 
to make sure that the category does not already exist is raising the 
exception because it does already exist. Which is good when I am actually 
creating categories in the database, not using an existing one when posting 
a question. My solution is to just perform the validation in the actual 
create method instead of the validate_category in CategorySerializer so 
that I can save a question with existing categories and still check that 
the category is unique when actually creating a new one?

-- 
You received this message because you are subscribed to the Google Groups 
"Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to