[Django] #34308: Feature request: Create Serializers for models

0 views
Skip to first unread message

Django

unread,
Feb 2, 2023, 3:59:56 PM2/2/23
to django-...@googlegroups.com
#34308: Feature request: Create Serializers for models
-------------------------------------+-------------------------------------
Reporter: Hemedbz | Owner: Hemedbz
Type: New | Status: assigned
feature |
Component: Core | Version: dev
(Serialization) |
Severity: Normal | Keywords: Serializer, Model
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
- Provide CLI to generate corresponding serializers for existing models
- The serializers will be in a seperate module named model_serializers.py,
and the serializers module will import from that.
- The default serializer for each model will include as fields all db
column names.
- The serializer default name will be the name of the model and serializer

Example:

{{{
#!python
class Coffee(models.Model):
type = models.Charfield(db_column='type')
roast_degree = models.IntegerFIeld(db_column='roast_degree)
temperature = models.IntegerFIeld(db_column='temperature')

class Meta:
db_table = 'coffee'
}}}

After running the function:
{{{
#!python
class CoffeeSerializer(serializers.ModelSerializer):
class Meta:
model = Coffee
fields = [
'type',
'roast_degree',
'temperature',
]

}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/34308>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Reply all
Reply to author
Forward
0 new messages