django-cms / django-filer

File and Image Management Application for django
https://django-filer.readthedocs.io/
Other
1.73k stars 574 forks source link

URL name "filer_file_fileicon" defined twice #1421

Closed stefan6419846 closed 9 months ago

stefan6419846 commented 9 months ago

We are employing a check for duplicate URL names in our applications and stumbled upon an issue when using django-filer: It seems like filer_file_fileicon is being defined/configured twice.

If I could pinpoint this correctly, the issue is about filer.admin.fileadmin.FileAdmin.get_urls defining the URL name filer_file_fileicon. filer.admin.imageadmin.ImageAdmin extends this class, but does not override get_urls, thus the duplicate is being generated.

https://github.com/django-cms/django-filer/blob/dbeda3a58cf1b30f9684f9ef328a5eb71f9a3f50/filer/admin/fileadmin.py#L166-L171 https://github.com/django-cms/django-filer/blob/dbeda3a58cf1b30f9684f9ef328a5eb71f9a3f50/filer/admin/imageadmin.py#L92-L94

I have been able to verify that using

class ImageAdmin(FileAdmin):
    change_form_template = 'admin/filer/image/change_form.html'
    form = ImageAdminForm

    def get_urls(self):
        result = super().get_urls()
        result = [x for x in result if x.name != 'filer_file_fileicon']
        return result

does indeed fix this specific issue, although I have not yet tested whether this might have other side effects.

fsbraun commented 9 months ago

@stefan6419846 Thanks for pointing this out! I think the issue is here in line 170: https://github.com/django-cms/django-filer/blob/dbeda3a58cf1b30f9684f9ef328a5eb71f9a3f50/filer/admin/fileadmin.py#L166-L171

The name should have the model name in lower case in the middle.