Re: Changing a form field's value during cleaning

2015-05-27 Thread Gergely Polonkai
In this case the problem comes if the user also filled the other ~60 non-approved fields and has to start over, which makes this approach a no-go for me :( 2015-05-27 10:25 GMT+02:00 James Schneider : > If you are able to catch the validation error, then perhaps you can

Re: Changing a form field's value during cleaning

2015-05-27 Thread James Schneider
If you are able to catch the validation error, then perhaps you can redirect users back to the original form URL (since the form should have the new correct values on the next load). Check out the form.invalid() when working with the form directly or form_invalid() for CBV's. If you catch that

Re: Changing a form field's value during cleaning

2015-05-27 Thread Gergely Polonkai
Hello, although the data is from the database, the form itself is not a ModelForm derivative. Also, this code you suggest will only modify the model handling part of the form, thus, the user will see a value he entered, although the database holds a different one. Best, Gergely 2015-05-27 9:16

Re: Changing a form field's value during cleaning

2015-05-27 Thread Klaas Feenstra
Hi, Maybe you can solve this in the views.py with commit=False https://docs.djangoproject.com/en/1.8/topics/forms/modelforms/ And from here you can render the new form with the initial data # Create a form instance with POST data.>>> f = AuthorForm(request.POST) # Create, but don't save the

Re: Changing a form field's value during cleaning

2015-05-26 Thread Gergely Polonkai
Because it is possible that user A will load the page, and user B will approve the field. On 27 May 2015 03:38, "Vijay Khemlani" wrote: > If some of the fields are "already approved" and thus they can't be > edited, why are you rendering those as editable form fields in the

Re: Changing a form field's value during cleaning

2015-05-26 Thread Vijay Khemlani
If some of the fields are "already approved" and thus they can't be edited, why are you rendering those as editable form fields in the first place? On Tue, May 26, 2015 at 9:55 PM, Gergely Polonkai wrote: > Hello, > > I'm currently having hard times changing a form field's

Changing a form field's value during cleaning

2015-05-26 Thread Gergely Polonkai
Hello, I'm currently having hard times changing a form field's value from within the form's clean() method. I have already tried setting self.initial[field_id] and manipulating the cleaned data by calling super's clean method, change the required field (cleaned_data[field_id]) and returning the