Monday, July 30, 2012

REMEMBER: To construct the form EXACTLY with populating the non-auto ModelForm populated fields.
Else, fields.clean() will complain onSubmit.





        if request.method == 'POST':
            self.product_edit_form = ProductEditForm(self.get_submit_data(), instance=self.product)
            self.create_product_edit_form()


            if not data.get('hidden_lang_change'): # A 'REAL' submit
                if self.product_edit_form.is_valid():
                    print "asdf", self.product_edit_form.cleaned_data
                    #TEST: A 'language change submit': repopulate some fields from the Property table AFTER creating the form
                    self.product_edit_form.fields['description'].help_text = "AFAVSVAAAS"
                    #self.product_edit_form.fields['description'].initial = "---AFAVSVAAAS---"
                    self.product_edit_form.cleaned_data['description'] = "NEW DESC"

                    self.product_edit_form = ProductEditForm(self.product_edit_form.cleaned_data, instance=self.product)
                    print "lalalalaa DON'T RETURN REDIRECT(...)"
                else:
                    self.product_edit_form.fields['description'].help_text = "zzzzzzzzzZZZZZZ"


                print "efgh"
            else: # A 'language change submit': repopulate some fields from the Property table AFTER creating the form
                pass












No comments:

Post a Comment