-
-
Notifications
You must be signed in to change notification settings - Fork 151
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
How to improve str() representation of relationships? Eg: when deleting from admin #96
Comments
No I have no good solution to this with the current implementation of sortedm2m. But we could ofcourse extend the SortedManyToManyField to support this usecase. I see the need you have and saw those not-so-nice string representations also a couple of times already.
What do you think? Would you be interested in working on a solution to your problem. I'm happy for any pull request. |
Both ideas would work. I'm inclined to prefer 2 because I think that would allow to customize more logic of the automatically generated "through" model. Is my supposition right? Yes I can work on this, I don't like to leave that monkey-patching in django-netjsonconfig. |
@gregmuellegger have you had any time to think about it? Would you prefer idea1 or idea2? |
@gregmuellegger I'm still keen to work on this. |
Yes, I would go with your recommendation. The Thanks for your on going interest :) |
Working on this. |
By reading the above thread and also the code, I've understood the following.
I've got some queries regarding this,
@nemesisdesign @gregmuellegger Please help. |
yes we need to add a by default the we need to add a way to supply a base class for the through model of |
So, I understand that I need to do two things,
Is it right? @nemesisdesign |
not right, you have to find a way to pass a base class that django-sortedm2m can use as a base for its through model. Look for |
I see. I'll go through once. |
@nemesisdesign @gregmuellegger : Please review PR #101 |
Fixes #96: Improve string representation of sortedm2m relationships
* Support Django up to 1.11, fix DeprecationWarnings Also set warnings to raise as errors in unit tests to prevent regressions that re-introduce the warnings. * Renamed duplicated TestStringReference classes jazzband#105 Fixes jazzband#105 * Add changelog for 1.4.0 release * Bump version to 1.4.0 * Prepare new dev version * Adding missing link to jazzband#104 in changelog * Fixes jazzband#96: Improve string representation of sortedm2m relationships
I have two models:
Config
andTemplate
(django-netjsonconfig),Config
has a sortedm2m relation toTemplate
.When deleting an object which has m2m relationships from admin interface, django says:
The repetition of
Config-template relationship: Config_templates object
conveys no information. I would like to display something more useful.For example, each config has a name, let's say I'm deleting a template which was installed on two config objects named
Auditorium
andGym
I've been able to accomplish this only through monkey patching:
But I'm wondering if there's a better way. Any suggestion?
The text was updated successfully, but these errors were encountered: