M django/contrib/admin/static/admin/js/admin/RelatedObjectLookups.js => django/contrib/admin/static/admin/js/admin/RelatedObjectLookups.js +8 -0
@@ 176,6 176,14 @@
}
});
$('.related-widget-wrapper select').trigger('change');
+ $('.related-lookup').click(function(e) {
+ e.preventDefault();
+ var event = $.Event('django:lookup-related');
+ $(this).trigger(event);
+ if (!event.isDefaultPrevented()) {
+ showRelatedObjectLookupPopup(this);
+ }
+ });
});
})(django.jQuery);
M django/contrib/admin/templates/admin/change_form.html => django/contrib/admin/templates/admin/change_form.html +0 -8
@@ 79,14 79,6 @@
showAddAnotherPopup(this);
}
});
- $('.related-lookup').click(function(e) {
- e.preventDefault();
- var event = $.Event('django:lookup-related');
- $(this).trigger(event);
- if (!event.isDefaultPrevented()) {
- showRelatedObjectLookupPopup(this);
- }
- });
{% if adminform and add %}
$('form#{{ opts.model_name }}_form :input:visible:enabled:first').focus()
M docs/releases/1.8.12.txt => docs/releases/1.8.12.txt +3 -0
@@ 15,3 15,6 @@ Bugfixes
* Fixed data loss on SQLite where ``DurationField`` values with fractional
seconds could be saved as ``None`` (:ticket:`26324`).
+
+* Restored the functionality of the admin's ``raw_id_fields`` in
+ ``list_editable`` (:ticket:`26387`).
M docs/releases/1.9.5.txt => docs/releases/1.9.5.txt +3 -0
@@ 37,3 37,6 @@ Bugfixes
* Fixed a regression in ``CommonMiddleware`` that caused spurious warnings in
logs on requests missing a trailing slash (:ticket:`26293`).
+
+* Restored the functionality of the admin's ``raw_id_fields`` in
+ ``list_editable`` (:ticket:`26387`).
M tests/admin_views/admin.py => tests/admin_views/admin.py +8 -0
@@ 1008,5 1008,13 @@ site.register(Group, GroupAdmin)
site2 = admin.AdminSite(name="namespaced_admin")
site2.register(User, UserAdmin)
site2.register(Group, GroupAdmin)
+site2.register(ParentWithUUIDPK)
+site2.register(
+ RelatedWithUUIDPKModel,
+ list_display=['pk', 'parent'],
+ list_editable=['parent'],
+ raw_id_fields=['parent'],
+)
+
site7 = admin.AdminSite(name="admin7")
site7.register(Article, ArticleAdmin2)
M tests/admin_views/tests.py => tests/admin_views/tests.py +17 -0
@@ 4667,6 4667,23 @@ class SeleniumAdminViewsFirefoxTests(AdminSeleniumWebDriverTestCase):
self.assertEqual(select.first_selected_option.text, uuid_id)
self.assertEqual(select.first_selected_option.get_attribute('value'), uuid_id)
+ def test_list_editable_raw_id_fields(self):
+ parent = ParentWithUUIDPK.objects.create(title='test')
+ parent2 = ParentWithUUIDPK.objects.create(title='test2')
+ RelatedWithUUIDPKModel.objects.create(parent=parent)
+ self.admin_login(username='super', password='secret', login_url=reverse('admin:index'))
+ change_url = reverse('admin:admin_views_relatedwithuuidpkmodel_changelist', current_app=site2.name)
+ self.selenium.get(self.live_server_url + change_url)
+ self.selenium.find_element_by_id('lookup_id_form-0-parent').click()
+ self.wait_for_popup()
+ self.selenium.switch_to.window(self.selenium.window_handles[-1])
+ # Select "parent2" in the popup.
+ self.selenium.find_element_by_link_text(str(parent2.pk)).click()
+ self.selenium.switch_to.window(self.selenium.window_handles[0])
+ # The newly selected pk should appear in the raw id input.
+ value = self.selenium.find_element_by_id('id_form-0-parent').get_attribute('value')
+ self.assertEqual(value, str(parent2.pk))
+
class SeleniumAdminViewsChromeTests(SeleniumAdminViewsFirefoxTests):
webdriver_class = 'selenium.webdriver.chrome.webdriver.WebDriver'