Where to write validation ?

Which one is the best practice to write the validation in django ?

  1. Validation in serialzier.
  2. Validation in models.

Welcome @therai0 !

There’s no one right answer here, nor are these options mutually exclusive.

You can add validation in both, depending upon your specific needs.

(Generally speaking, you can validate within the model for those elements that can be validated within the context of that model instance. You can validate in the serializer for all other situations. But, neither of these general principles are absolutes.)