DEV Community

Papan Sarkar
Papan Sarkar

Posted on

Don't write queries inside serializers in Django!

Don't Do it

Why?

  • It should focus data conversion and validations only. Don't write database logic on this.

  • Not efficient and bad performance. It will create lots of queries

  • You can not reuse it

  • Very hard to test

  • Readability is gone

I can share the alternatives if you want! Let me know

Top comments (0)

Qodo Takeover

Introducing Qodo Gen 1.0: Transform Your Workflow with Agentic AI

Rather than just generating snippets, our agents understand your entire project context, can make decisions, use tools, and carry out tasks autonomously.

Read full post