Il 22/11/2015 22:02, Florian Demmer ha scritto:
>
>
> On 2015-11-22 21:31, Riccardo Magliocchetti wrote:
>> Hi Florian,
>>
>> Il 22/11/2015 21:14, Florian Demmer ha scritto:
>>> Hi guys,
>>>
>>> i am confused/surprised by this ticket and already merged feature. it took me a
>>> while to find out what was happening in my admin:
>>>
>>>
https://code.djangoproject.com/ticket/14497
>>>
>>> Imho, the automatically added link to the file should *not* have precedence over
>>> `list_display_links` and definitely should *not* break the automatically added
>>> link to the change_view, when the `FileField` happens to be first in
>>> `list_display`.
>>>
>>> What do you think?
>>
>> Since you seem to care about this, any chance to open a pull request? The pull
>> request should contain updated tests to verify that the double <a> link is
>> fixed please. If not i'll give a try of fixing it later this week.
>>
> since both admin views use that same function, i am not sure how easy it will be
> to fix without adding a whole bunch of more code just to detect the field type
> and checking list_display_links etc... i'll probably not find the time to look
> into that until next weekend either.
>
> as a workaround i have added the 'id' field in first place to my list_display.
I finally found time to look at this and on master it does not break at least,
am i missing something?
diff --git a/tests/admin_widgets/tests.py b/tests/admin_widgets/tests.py
index 46f2d2a..469a068 100644
--- a/tests/admin_widgets/tests.py
+++ b/tests/admin_widgets/tests.py
@@ -444,6 +444,12 @@ class AdminFileWidgetTests(TestDataMixin, TestCase):
File widgets should render as a link when they're marked "read only."
"""
self.client.login(username="super", password="secret")
+ response = self.client.get(reverse('admin:admin_widgets_album_changelist'))
+ self.assertContains(
+ response,
+ '<th class="field-__str__"><a
href="/admin_widgets/album/1/change/">Hybrid Theory</a></th>',
+ html=True,
+ )
response = self.client.get(reverse('admin:admin_widgets_album_change',
args=(
self.album.id,)))
self.assertContains(
response,
diff --git a/tests/admin_widgets/widgetadmin.py b/tests/admin_widgets/widgetadmin.py
index 6b205b7..6287266 100644
--- a/tests/admin_widgets/widgetadmin.py
+++ b/tests/admin_widgets/widgetadmin.py
@@ -25,7 +25,7 @@ class EventAdmin(admin.ModelAdmin):
class AlbumAdmin(admin.ModelAdmin):
- fields = ('name', 'cover_art',)
+ fields = ('cover_art',)
readonly_fields = ('cover_art',)