Opened 13 years ago

Closed 11 years ago

Last modified 11 years ago

#16965 closed Bug (fixed)

Model Formsets can_delete documentation lacking actual use example

Reported by: gregcorey@… 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)

16965.diff (1.6 KB ) - added by Tim Graham 11 years ago.

Download all attachments as: .zip

Change History (13)

comment:1 by Yaşar Arabacı, 13 years ago

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 an int object, an int object doesn't have a delete() 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.

comment:2 by geraldcor, 13 years ago

Summary: Formsets can_delete documentation lacking actual use exampleModel 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 Yaşar Arabacı, 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 geraldcor, 13 years ago

Keywords: model formset added; formsets removed

comment:5 by Aymeric Augustin, 13 years ago

Triage Stage: UnreviewedAccepted

I just discussed this with Julien, and we don't really know how this feature is supposed to be used. It really needs documentation.

Version 0, edited 13 years ago by Aymeric Augustin (next)

comment:6 by Amanjeev Sethi, 12 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.

in reply to:  6 comment:7 by geraldcor, 12 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.

Last edited 12 years ago by geraldcor (previous) (diff)

by Tim Graham, 11 years ago

Attachment: 16965.diff added

comment:8 by Tim Graham, 11 years ago

Has patch: set

comment:9 by Tim Graham, 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 Tim Graham <timograham@…>, 11 years ago

Resolution: fixed
Status: newclosed

In 660c30ed953667b44bdec7058dafe10e0a8ce402:

Fixed #16965 -- Clarified Formset can_delete docs.

Thanks gregcorey@ for the suggestion.

comment:11 by Tim Graham <timograham@…>, 11 years ago

In 5567dc68e6fc7788cd9451e5fea52396ffaf3675:

[1.5.x] Fixed #16965 -- Clarified Formset can_delete docs.

Thanks gregcorey@ for the suggestion.

Backport of 660c30ed95 from master

comment:12 by geraldcor, 11 years ago

Thanks guys! I didn't realize this would become such a long process. :-)

Note: See TracTickets for help on using tickets.
Back to Top