Resolve resource type in serializer's meta class
See original GitHub issueutils.get_resource_type_from_serializer
is called several times throughout the DJA code base. When this method raises an AttributeError
it is a configuration/code setup issue and not a runtime issue. Besides there is no error message describing want went wrong.
Goals:
- move logic of
get_resource_type_from_serializer
to serializer’s meta class - improve error handling (better error message).
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (8 by maintainers)
Top Results From Across the Web
Serializers - Django REST framework
The Serializer class is itself a type of Field , and can be used to represent relationships where one object type is nested...
Read more >Docs on serializer Meta class inheritance? #1926 - GitHub
This seems like a common case. I have a base model with control fields (id, created, modified, lat, lon , ip, user, group...
Read more >Could not resolve URL for hyperlinked relationship using view ...
My final serializer and ViewSet implementations were as simple as this! class MessageSerializer(serializers.HyperlinkedModelSerializer): class Meta: model = ...
Read more >Serializers - Django REST framework - Tom Christie
We'll declare a serializer that we can use to serialize and deserialize Comment objects. ... The first part of serializer class defines the...
Read more >Usage - Django REST framework JSON:API - Read the Docs
If you set the resource_name on a combination of model, serializer, or view in the same hierarchy, the name will be resolved as...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
While we are at this, what do you think if we allowed serializers themselves to define what kind of type they are, via a function? This would overwrite the attribute access. Something very similar to what DRF does with
queryset/get_queryset
andserializer_class/get_serializer_class
in views. This would help for polymorphic relations, generic relations and custom non-ORM relations and serializers.I’m also thinking if we make
included_serializers
andincluded_resources
the same way. This also would help polymorphic relations, generic relations and custom non-ORM relations and serializers.