Sitemap
Level Up Python

Level Up Python shares day-to-day Python lessons — from zero to advanced. We cover scripting, web dev, automation, AI/ML, and more. Python isn’t just a language — it’s a mindset. Learn to write smarter, cleaner, and more powerful code, one level at a time.

Member-only story

Writing My Own Django Serializer for camelCase — Until I Found the One-Line Fix

--

Generated with ChatGPT

Not a paid member? Read here for FREE!

When you’re building a Django REST API and the frontend is speaking fluent camelCase while Django insists on snake_case… you end up playing translator.

And it’s annoying. Every request is a mess of renamed fields, unnecessary mappings, and serializers that look like a jungle of overridden variables.

Let’s be real — this isn’t where you want to spend your energy.

Take a basic Django REST Framework (DRF) model, for example:

class User(models.Model):
first_name = models.CharField(max_length=100)
last_name = models.CharField(max_length=100)

When serialized, this becomes:

{
"first_name": "John",
"last_name": "Doe"
}

That’s fine for Django. But your frontend dev? They’re expecting:

{
"firstName": "John",
"lastName": "Doe"
}

Sure, you can manually map every field:

class UserSerializer(serializers.ModelSerializer):
fullName = serializers.CharField(source='full_name')
createdAt = serializers.DateTimeField(source='created_at')

--

--

Level Up Python
Level Up Python

Published in Level Up Python

Level Up Python shares day-to-day Python lessons — from zero to advanced. We cover scripting, web dev, automation, AI/ML, and more. Python isn’t just a language — it’s a mindset. Learn to write smarter, cleaner, and more powerful code, one level at a time.

Lakshitha
Lakshitha

Written by Lakshitha

BSc (Hons) in Computer Science | Exploring Ideas, Systems, and Flow | linkedin.com/in/lakshithe/

No responses yet