I think that the usability of ForeignKeyRawIdWidget could be vastly improved if the representation part of the widget (the object name, in bold) were to be updated when a new object gets chosen. I think this could be done relatively easily with a small change introducing little extra complexity.At present the original representation remains, which is confusing to users and could lead to mistakes being made.I think this can't be done simply by a 3rd party app without some seriously dirty monkey patching. The only way I can think of I to do it without monkey patching would be to make ajax requests to get the new representation of the chosen object - substantially more awkward both for the developer and the person installing the app.I appreciate some people will have used ForeignKeyRawIdWidget outside admin and used a custom dismissRelatedLookupPopup function so ideally any change would not break their code. This means that the function signature of dismissRelatedLookupPopup should remain the same (unfortunately, as this would be the most obvious and easiest place to include representation).My proposal would be for the string representation of the object to be included somewhere in the popup - for example as an html attribute called data-object-representation on the anchor with the onclick handler. If this anchor was also given an id (say choose-object-X where X is the object's pk) then it would be easily accessible to the dismissRelatedLookupPopup, which could extract it and update the representation on the calling page. The <strong> elem containing the representation might also benefit from having a unique id as RelatedObjectLookups.js seems to be written so as not to require jQuery.Hope that all makes sense. Naturally I'm prepared to write a patch for this assuming it doesn't meet with disapproval.Thanks,RichardP.S. Hope I'm putting this in the right place, and I couldn't find anything existing on the django issues list, and i got the impression that this list was the place to start with such things.
I think that the usability of ForeignKeyRawIdWidget could be vastly improved if the representation part of the widget (the object name, in bold) were to be updated when a new object gets chosen. I think this could be done relatively easily with a small change introducing little extra complexity.At present the original representation remains, which is confusing to users and could lead to mistakes being made.I think this can't be done simply by a 3rd party app without some seriously dirty monkey patching. The only way I can think of I to do it without monkey patching would be to make ajax requests to get the new representation of the chosen object - substantially more awkward both for the developer and the person installing the app.I appreciate some people will have used ForeignKeyRawIdWidget outside admin and used a custom dismissRelatedLookupPopup function so ideally any change would not break their code. This means that the function signature of dismissRelatedLookupPopup should remain the same (unfortunately, as this would be the most obvious and easiest place to include representation).My proposal would be for the string representation of the object to be included somewhere in the popup - for example as an html attribute called data-object-representation on the anchor with the onclick handler. If this anchor was also given an id (say choose-object-X where X is the object's pk) then it would be easily accessible to the dismissRelatedLookupPopup, which could extract it and update the representation on the calling page. The <strong> elem containing the representation might also benefit from having a unique id as RelatedObjectLookups.js seems to be written so as not to require jQuery.Hope that all makes sense. Naturally I'm prepared to write a patch for this assuming it doesn't meet with disapproval.Thanks,RichardP.S. Hope I'm putting this in the right place, and I couldn't find anything existing on the django issues list, and i got the impression that this list was the place to start with such things.
On 13 June 2013 03:33, <ric...@richard.ward.name> wrote:
I think that the usability of ForeignKeyRawIdWidget could be vastly improved if the representation part of the widget (the object name, in bold) were to be updated when a new object gets chosen. I think this could be done relatively easily with a small change introducing little extra complexity.
The handling of raw IDs, particularly in a comma-separated list for many-to-many relationships, is arguably the biggest user-facing "wart" in the current admin implementation. The sheer number of available related objects often makes listing the full set in a dropdown or other widget unfeasible, forcing developers to resort to the raw ID mechanism to a) improve efficiency in terms of database-querying and response/DOM-size, and b) make the selection interface manageable and allow searching/filtering/pagination/etc. Providing a textual representation of the object as per the standard widgets makes sense here.