Skip to content

Unable to create root folder if the name is duplicated from a child folder #1521

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

Open
bachvtuan opened this issue Apr 10, 2025 · 3 comments
Open
Assignees

Comments

@bachvtuan
Copy link

Sample:
I have "RootFolder" and its child folder "SubFolder"
I can't create another root folder with name "SubFolder"

@fsbraun
Copy link
Member

fsbraun commented Apr 10, 2025

@bachvtuan I cannot reproduce this.

Which version are you using?
Do you have any filer-specific settings?

@bachvtuan
Copy link
Author

bachvtuan commented Apr 10, 2025

Version: django-filer-3.3.1
@fsbraun I found out FILER_ENABLE_PERMISSIONS=True
Not sure that is a feature or a bug.

@fsbraun
Copy link
Member

fsbraun commented Apr 10, 2025

All right, setting FILER_ENABLE_PERMISSIONS = True seems to cause the issue. I'll have a look.

The culprit might be here. I need to find out why this is happening:

folder_form = super().get_form(
request, obj=None, **kwargs)
def folder_form_clean(form_obj):
cleaned_data = form_obj.cleaned_data
folders_with_same_name = self.get_queryset(request).filter(
parent=form_obj.instance.parent,
name=cleaned_data['name'])
if form_obj.instance.pk:
folders_with_same_name = folders_with_same_name.exclude(
pk=form_obj.instance.pk)
if folders_with_same_name.exists():
raise ValidationError(
'Folder with this name already exists.')
return cleaned_data
# attach clean to the default form rather than defining a new form class
folder_form.clean = folder_form_clean
return folder_form

@fsbraun fsbraun self-assigned this Apr 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants