Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

URL name "filer_file_fileicon" defined twice #1421

Closed
stefan6419846 opened this issue Sep 11, 2023 · 1 comment
Closed

URL name "filer_file_fileicon" defined twice #1421

stefan6419846 opened this issue Sep 11, 2023 · 1 comment

Comments

@stefan6419846
Copy link

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.

def get_urls(self):
return super().get_urls() + [
path("icon/<int:file_id>/<int:size>",
self.admin_site.admin_view(self.icon_view),
name="filer_file_fileicon")
]
class ImageAdmin(FileAdmin):
change_form_template = 'admin/filer/image/change_form.html'
form = ImageAdminForm

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
Copy link
Member

fsbraun commented Sep 18, 2023

@stefan6419846 Thanks for pointing this out! I think the issue is here in line 170:

def get_urls(self):
return super().get_urls() + [
path("icon/<int:file_id>/<int:size>",
self.admin_site.admin_view(self.icon_view),
name="filer_file_fileicon")
]

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants