#16965 closed Bug (fixed)
Model Formsets can_delete documentation lacking actual use example
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | Documentation | Version: | 1.3 |
Severity: | Normal | Keywords: | can_delete, documentation, model formset |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Formsets can_delete online documentation provides no example of how to utilize this parameter to actually delete a form.
Something along the lines of:
for form in formset.deleted_forms: form.cleaned_data['id'].delete()
is all that is needed (if that is indeed the correct way to do it - I don't know because there is no documentation that I could find :) ).
Thanks.
Attachments (1)
Change History (13)
comment:1 by , 13 years ago
comment:2 by , 13 years ago
Summary: | Formsets can_delete documentation lacking actual use example → Model Formsets can_delete documentation lacking actual use example |
---|
You are correct. This is for model formsets. That is the use case that should be pretty standard. We want to delete that particular model instance - that is the whole point of the modelform / modelformset feature. So that is why I think it should be better documented (I was actually surprised that form.cleaned_data['id']
returned a model instance ripe for deleting)
I have changed the bug title to reflect Model Formsets as the area requiring documentation.
comment:3 by , 13 years ago
In this case, it is better to wait for a core developer to explain actual usage example of this feature. After than, I can submit a patch about this.
comment:4 by , 13 years ago
Keywords: | model formset added; formsets removed |
---|
comment:5 by , 13 years ago
Triage Stage: | Unreviewed → Accepted |
---|
I just discussed this with Julien, and we don't know how this feature is supposed to be used. It really needs documentation.
follow-up: 7 comment:6 by , 13 years ago
Formsets can_delete online documentation provides no example of how to utilize this parameter to actually delete a form
When you say "actually delete a form", you mean delete the object that, that particular form relates to, correct?
I just want to make sure that we are not deleting a form from the front-end end. Rather, this is a feature that is used to delete the object.
comment:7 by , 13 years ago
Replying to amanjeev:
Formsets can_delete online documentation provides no example of how to utilize this parameter to actually delete a form
When you say "actually delete a form", you mean delete the object that, that particular form relates to, correct?
I just want to make sure that we are not deleting a form from the front-end end. Rather, this is a feature that is used to delete the object.
Yes that is correct. It is the object that the model_formset represents. I apologize for the hastiness of the bug.
by , 11 years ago
Attachment: | 16965.diff added |
---|
comment:8 by , 11 years ago
Has patch: | set |
---|
comment:9 by , 11 years ago
I'm not sure there's a need to document a usage example as ModelFormSet
automatically deletes instances for deleted_forms
when you call formset.save()
. I've added a patch which explains this.
comment:10 by , 11 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:12 by , 11 years ago
Thanks guys! I didn't realize this would become such a long process. :-)
I think it's because there is no general way of saving or deleting a form. On the other hand, your example looks completely wrong to me because,
form.cleaned_data['id']
would return anint
object, an int object doesn't have adelete()
method. But for model formsets, there might be a quick way to demonstrate this feature, as they might define a quick way to delete an object.