Skip to main content

DRF Verbose Serializers

A Django REST Framework extension that allows you to use verbose field names in your serializers.

Installation

pip install drf-verbose-serializers

Features

  • Adds verbose_field_name parameter to DRF serializer fields
  • Allows customizing serializer output field names without changing the underlying model or serializer field names
  • Supports nested serializers with many=True relationships
  • Includes mixins for both ModelSerializer and Serializer classes

Usage

Basic Example

from rest_framework import serializers
from drf_verbose_serializers import VerboseModelSerializerMixin, VerboseCharField, VerboseIntegerField

class UserSerializer(VerboseModelSerializerMixin, serializers.ModelSerializer):
    username = VerboseCharField(verbose_field_name='Username')
    email = VerboseCharField(verbose_field_name='Email Address')
    age = VerboseIntegerField(verbose_field_name='Age')

    class Meta:
        model = User
        fields = ['username', 'email', 'age']

This will produce JSON like:

{
    "Username": "johndoe",
    "Email Address": "john@example.com",
    "Age": 30
}

Using with Regular Serializers

from rest_framework import serializers
from drf_verbose_serializers import VerboseSerializerMixin, VerboseCharField, VerboseIntegerField

class UserSerializer(VerboseSerializerMixin, serializers.Serializer):
    username = VerboseCharField(verbose_field_name='Username')
    email = VerboseCharField(verbose_field_name='Email Address')
    age = VerboseIntegerField(verbose_field_name='Age')

Nested Serializers

from rest_framework import serializers
from drf_verbose_serializers import (
    VerboseModelSerializerMixin, 
    VerboseCharField,
    VerbosePrimaryKeyRelatedField
)

class CommentSerializer(VerboseModelSerializerMixin, serializers.ModelSerializer):
    text = VerboseCharField(verbose_field_name='Comment Text')
    
    class Meta:
        model = Comment
        fields = ['text']

class PostSerializer(VerboseModelSerializerMixin, serializers.ModelSerializer):
    title = VerboseCharField(verbose_field_name='Post Title')
    body = VerboseCharField(verbose_field_name='Post Body')
    comments = CommentSerializer(many=True, verbose_field_name='Post Comments')
    
    class Meta:
        model = Post
        fields = ['title', 'body', 'comments']

Available Fields

All standard DRF fields are supported with verbose name variants:

  • VerboseCharField
  • VerboseIntegerField
  • VerboseBooleanField
  • VerboseDateTimeField
  • VerboseDateField
  • VerboseFloatField
  • VerboseDecimalField
  • VerboseEmailField
  • VerboseSerializerMethodField
  • VerboseRelatedField
  • VerbosePrimaryKeyRelatedField
  • VerboseHyperlinkedRelatedField
  • VerboseSlugRelatedField
  • VerboseHyperlinkedIdentityField
  • VerboseListField
  • VerboseDictField
  • VerboseJSONField
  • VerboseStringRelatedField

License

MIT

Metadata

Release files for drf-verbose-serializers 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for drf-verbose-serializers 0.1.0
File Size Uploaded
drf_verbose_serializers-0.1.0.tar.gz 5.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for drf-verbose-serializers 0.1.0
File Interpreter ABI Platform
drf_verbose_serializers-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 10.4 kB

Release files / drf_verbose_serializers-0.1.0.tar.gz

Download URL drf_verbose_serializers-0.1.0.tar.gz
Size 5.2 kB
Tags Source
SHA-256 checksum
How to use checksums
8c8cb024ee22bca941be47403ab3912113461d2403d8e8ee71a6be143e791262
BLAKE2b-256 checksum
How to use checksums
db846d07b9925d222f376c7ddc07ccaf7373d7fddeda7a2e5857de29e1b8108a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.12

Release files / drf_verbose_serializers-0.1.0-py3-none-any.whl

Download URL drf_verbose_serializers-0.1.0-py3-none-any.whl
Size 5.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5e49503fda49ec2c1db22d69a550330f3f6afd49e770569ef6da241479e293a5
BLAKE2b-256 checksum
How to use checksums
038580c6cdf26bda97ac815345a9782e3a765954038fdad20c235b4727f4ebbb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.12

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page