jazzband / django-formtools

A set of high-level abstractions for Django forms
https://django-formtools.readthedocs.io
BSD 3-Clause "New" or "Revised" License
816 stars 136 forks source link

Class based view update for FormPreview #19

Open gchp opened 10 years ago

gchp commented 10 years ago

This issue was originally submitted on Trac (#16174). Please see that ticket for the original conversation.

NOTE: There are a few patches attached to the Trac ticket which may be useful.


I used the FormPreview class in formtools.preview for the first time this week. After working with class based views for a while, I really missed methods like get_form for custom form instantiation. Recently, the form wizard machinery (which is much more complex) got a class-based views update (#9200) so I decided to update the FormPreview class as well. It uses django.views.generic.FormView and it's on a Django branch on my Github account. (​https://github.com/ryankask/django/blob/cbv-formpreview/django/contrib/formtools/preview.py -- I've also attached a diff based on the Django Github mirror which I am pretty sure is acceptable.

In order to maintain 100% compatibility, there are some issues to note:

If backwards compatibility doesn't need to be maintained, the code can be cleaned up a little more.

Anyway, any comments on the patch would be much appreciated and I'd update the docs if devs think it's okay.

By the way, if none of this is acceptable, the test formtools.PreviewTests.test_form_submit_bad_hash needs to be fixed (it is in my patch). self.client.post('/previewpreview/', self.test_data) results in a 404 so the next assertion that some text isn't in the template passes when it shouldn't.

jannh commented 9 years ago

Probably this is of interest for you. I wrote a Mixin which adds the preview functionality to the default Django-CBVs. Maybe something like this could additionally (or instead the current preview) be included into the formtools? I put the mixin on django-snippets just a few minutes ago: https://djangosnippets.org/snippets/10475/

jbinary commented 7 years ago

So why is this one abandoned?

I think that the current implementation is actually a dangerous one because it's not thread safe storing the state in the instance while the instance is the same for all the request to a view?

auvipy commented 7 years ago

there wasn't any contributor to complete it