#11163: admin ForeignKeyRawIdWidget contains incorrect link when used in change list view -----------------------------------------------+---------------------------- Reporter: margierogin...@yahoo.com | Owner: nobody Status: new | Milestone: Component: Uncategorized | Version: 1.0 Resolution: | Keywords: Stage: Unreviewed | Has_patch: 0 Needs_docs: 0 | Needs_tests: 0 Needs_better_patch: 0 | -----------------------------------------------+---------------------------- Old description:
> When the user specifies in their admin.py that a field is both editable > and a raw_id, like this: > > list_editable = ('owner',) > raw_id_fields = ('owner',) > > the ForeignKeyRawIdWidget is used in the change list view for that field. > However, the code in the ForeignKeyRawIdWidget's render() method is > hardcoded to be called from the edit form, with the following code: > > related_url = '../../../%s/%s/' % (self.rel.to._meta.app_label, > self.rel.to._meta.object_name.lower()) > > When called from the change list, the url has one less entry than when > called from the edit form. As a result, the link is wrong when called > from the change list. For example, the url for the changelist is > something like this: > > http://mysite.com/admin/taskmanager/task/ > > while the url from the edit form is like this: > > http://mysite.com/admin/taskmanager/task/1 > > So when used in the change list, the raw id widget's link ends up > pointing to http://mysite.com/auth/user/?t=id rather than > http://mysite.com/admin/auth/user/?t=id New description: When the user specifies in their admin.py that a field is both editable and a raw_id, like this: {{{ list_editable = ('owner',) raw_id_fields = ('owner',) }}} the ForeignKeyRawIdWidget is used in the change list view for that field. However, the code in the ForeignKeyRawIdWidget's render() method is hardcoded to be called from the edit form, with the following code: {{{ related_url = '../../../%s/%s/' % (self.rel.to._meta.app_label, self.rel.to._meta.object_name.lower()) }}} When called from the change list, the url has one less entry than when called from the edit form. As a result, the link is wrong when called from the change list. For example, the url for the changelist is something like this: http://mysite.com/admin/taskmanager/task/ while the url from the edit form is like this: http://mysite.com/admin/taskmanager/task/1 So when used in the change list, the raw id widget's link ends up pointing to http://mysite.com/auth/user/?t=id rather than http://mysite.com/admin/auth/user/?t=id Comment (by ramiro): (reformatted description) -- Ticket URL: <http://code.djangoproject.com/ticket/11163#comment:1> Django <http://code.djangoproject.com/> The Web framework for perfectionists with deadlines. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django updates" group. To post to this group, send email to django-updates@googlegroups.com To unsubscribe from this group, send email to django-updates+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-updates?hl=en -~----------~----~----~----~------~----~------~--~---