Replies: 5 comments 4 replies
-
Interesting use-case. I somehow have a problem with this from a UX perspective: A user shall have always have the possibility to undo an action which he previously executed. If by accident he clicked onto the "Add …"-button, then he wouldn't have that possibility anymore and this can lead to frustration and even panic. |
Beta Was this translation helpful? Give feedback.
-
My use case is a Facility with Units. Every facility when created automatically gets a default unit with a 'special' name. This one should not be deleted OR changed. A User can add or delete Units - certainly the ones they add - but not the default one. Yet I do want the default one to show up in the list of units when viewing the facility. |
Beta Was this translation helpful? Give feedback.
-
I assume that you have a definition similar to this: class UnitForm(ModelForm):
# some fields
class UnitCollection(FormCollection):
min_siblings = 1
max_siblings = ...
unit = UnitForms(…)
class FacilityForm(ModelForm):
# some fields
class FacilityCollection(FormCollection):
facility = FacilityForm()
units = UnitCollections() How about refactoring the class FacilityCollection(FormCollection):
facility = FacilityForm()
default_unit = UnitForm()
units = UnitCollections() you then achieve what you want, without having to change the core implementation of django-formset. |
Beta Was this translation helpful? Give feedback.
-
Well, ordering than only works for the non-default |
Beta Was this translation helpful? Give feedback.
-
I just can't get it work!
Problem is that the default_unit keeps getting the data from the parent instance; the Facility. I have tried setting the instance which didn't work. Will using |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
When using a formset factory in Django you can use the parameter can_delete to control whether to allow deleting of the formset members. Can this be done in Django-formset?
It would be nice to have the ability for each member of the collection control whether it can be deleted or not.
If this cannot be done currently in Django-formset what would be the best way for me implement this?
Beta Was this translation helpful? Give feedback.
All reactions