-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fields that are ForeignKey
s to other models render as pk
, not as the string representation of that model
#41
Comments
Hey @joshuadavidthomas — yes, makes sense. Is this something you'd do a PR for? |
I this open to take ? |
@wassafshahzad Yes, great. Please keep the fix to just this issue here, not blending with #39 and #40, as the linked commit does. (I need to look at those separately. A test case for the change will be needed. Thanks! Let me know if you get stuck anywhere. |
@carltongibson any specific reason you didn't use It looks to me like a pretty simple fix but I'm fearing it's too simple |
No real reason. It just didn't occur to me when I was bashing it together. This is probably a change we should make yes. There are a couple of related issues about the table generation and the actions links that likely go together. The reason they're still here is I didn't get a chance to totally think them through yet, but happy to have input. |
A possible solution for rendering Foreignkey as PK #41Hey , I am Parthib. Saw the project architechture and tried to give an approach to solve -
|
In the
object_list
andobject_detail
templatetags, a field's value is rendered using the field'svalue_to_string
method. On fields that are aForeignKey
to another model, this just renders that model's primary key, not the string representation of the model.Before:
If you change how the field's value is rendered by getting the attribute and rendering to string, you can get that related model's string representation.
After:
See this relevant commit for what this would look like.
The text was updated successfully, but these errors were encountered: