question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Resolve resource type in serializer's meta class

See original GitHub issue

utils.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:open
  • Created 2 years ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
SafaAlfulaijcommented, Dec 31, 2021

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 and serializer_class/get_serializer_class in views. This would help for polymorphic relations, generic relations and custom non-ORM relations and serializers.

0reactions
SafaAlfulaijcommented, Jan 4, 2022

I’m also thinking if we make included_serializers and included_resources the same way. This also would help polymorphic relations, generic relations and custom non-ORM relations and serializers.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found