Skip to content

StringRelatedField() not working #1234

Answered by sliverc
Jer-Pha asked this question in Q&A
Discussion options

You must be logged in to vote

Thanks for bringing this up. It seems that in DJA we have not covered the use case of StringRelatedField so that is the reason it is not working. Feel free to create an issue for this.

As a workaround though, what you can do is to create your own ResourceRelatedField and overwrite get_resource_id to return a string. You can use this field instead of StringRelatedField.

This could look like the following:

class StringResourceRelatedField(ResourceRelatedField):
    def get_resource_id(self, resource):
        return str(resource)

Using such a field would have the same effect as StringRelatedField but would of course only work with the DJA renderer.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Jer-Pha
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy