How to save submitted form image field before clean method in Form Wizard (Django 1.2)

I get "This field is required" error for image field on submitting a form in Form Wizard.

class SignupForm(forms.ModelForm): username = forms.CharField( label = _("Username*"), max_length = 30, widget = forms.TextInput() ) image = forms.ImageField(label = _("Profile picture*"), required=True) class Meta: model = Profile fields = ('name','gender','birth_date',)

This is my last form in form wizard. On submitting this form I got username and other fields in clean method but not the image. Is there a way to save image before validation of this form to avoid "This field is required" error?

-------------Problems Reply------------

To upload your images through Form Wizard you should change the file "django/contrib/formtools/wizard.py". These changes are mentioned in this Ticket code.djangoproject.com/ticket/7439. If you dont want to change djnago code then simply copy "formtools" folder into your apps then make changes there and instead of using:

from django.contrib.formtools.wizard import FormWizard

use:

from formtools.wizard import FormWizard

Also set enctype="multipart/form-data" of your template form.

Category:django Views:0 Time:2011-11-16

Related post

  • How to save a field added in the clean() method? 2011-07-18

    My form has first_name and last_name fields, but my model has just a name field. In the clean() method of the form I set self.cleaned_data['name'], but when I try to save it I get this error: <ul class="errorlist"><li>name<ul class="er

  • Best method for submitting disabled form fields in jQuery? 2012-01-13

    There seem to be several ways to submit (POST) disabled form fields in jQuery: Have a hidden field that changes when the input changes, and submit that Manually append the key/value pairs upon submission Revert values on the server-side (only if valu

  • Modify value of a Django form field during clean() 2009-03-17

    I am adding custom validation to my forms and custom fields in my Django app. I would like to be able to modify the value of a field when triggering an error. For example, if there is an error, the form should be redisplayed with the field value corr

  • What is the difference between a Model field type and a similar validator in Django? 2012-03-03

    What is the difference between, say, a EmailField and a validator_email? And is it a bad idea to use both? Or for those who perfer code import django.db import models email = models.EmailField() vs import django.db import models email = models.CharFi

  • Private fields inside private methods VS pass them from public methods 2012-04-24

    What is the better way to work with private field and private methods? Is it graceful to use private field inside private methods or it's better to put them as parameters,when call private method from public method? field: private Item model; 1. publ

  • What causes Firefox to make a GET request after submitting a form via the POST method? 2008-09-18

    What causes Firefox to follow a POST request with a GET request when submitting a form via the POST method? The GET method is sent to the same url as the POST method but without the request parameters. If you change the form method to GET, it will re

  • How do I hide the field label for a HiddenInput widget in Django Admin? 2009-09-11

    I've got a bit of Django form code that looks like this: class GalleryAdminForm(forms.ModelForm): auto_id=False order = forms.CharField(widget=forms.HiddenInput()) And that makes the form field go away, but it leaves the label "Order" in the Django a

  • Django field required in a clean method in a form class 2009-10-29

    I want to redefine the required attribute for a field in a clean method of my form file: class NewUserFullForm(NewUserForm): REGEX_PHONE = '^(\+[0-9]{2})[ \.\-]?[0-9][ \.\-]?[0-9]{2}[ \.\-]?[0-9]{2}[ \.\-]?[0-9]{2}[ \.\-]?[0-9]{2}$' phone = forms.Reg

  • Is it necessary to check all the field in equals method of model class in JPA? 2010-04-15

    Is it necessary to check all the field in equals method of model class in JPA, or can I use only id? --------------Solutions------------- No, it's not necessary to put all of your fields in the equals method just because you're using JPA. In fact, JP

  • Field Members vs Method Variables? 2010-05-11

    Recently I've been thinking about performance difference between class field members and method variables. What exactly I mean is in the example below : Lets say we have a DataContext object for Linq2SQL class DataLayer { ProductDataContext context =

  • When a form clean() method detects an error, how do I redisplay empty fields instead of the user's input? 2011-07-20

    When the clean() method of my Django form detects an error, I'd like the form fields to redisplay as empty instead of filling in whatever input the user provided. How do I do this? Is it a property of the form field itself, or is it done in the clean

  • Magento custom field in shipping method 2011-09-03

    How to add a field in shipping method dhl in admin area in magento? --------------Solutions------------- Admin config fields are added with system.xml field description. Look at this extension etc/system.xml and add your config field there

  • Raising ValidationError in a custom field's to_python() method breaks admin forms 2012-01-17

    I have a custom field called CustomField to wrap a class called Example like so: from django import forms from django.db import models from . import Example class CustomField(models.CharField): __metaclass__ = models.SubfieldBase def to_python(self,

  • Difference between Compress and Clean method in Django Form Fields 2012-04-07

    I'm writing a custom date field for Credit Card Expiration Fields. I've noticed that in custom field examples, there are two major part that we need to override, clean and compress methods. I know that we can validate and change return values of the

  • Submitting multi-stage form using .load method 2012-04-16

    I've been looking at this multi-stage form at http://jsfiddle.net/xSkgH/89/ and was just wondering about the best way of submitting the form using the .load method. I've been trying this so far: <script type="text/javascript"> $(document).ready

  • Before save action- split input field 2010-10-09

    I have two models and controllers: Snippets, and Tags. There is a belongs_to relationship, with tags belonging to snippets. This works well, I have a text field which creates a new tag associated with the snippet when the user submits a snippet. I wa

  • Why is Chrome submitting extra form fields? Is it a bug with Chrome? 2009-07-16

    I have a form being inserted into a page with jQuery. In all other browsers, it submits correctly... but in Chrome, some extra form fields from other forms on the page are being added to the POST. I'm not using javascript to submit the form, the form

  • save dynamically created form fields between page requests 2009-08-07

    I have a form in which the user can dynamically add/remove name/value pairs of fields eg: inventory list: [description text input field] [quantity text input field] [remove item button] [add item button] so basically the user can add more inventory i

  • Save other model's fields from a certain view 2009-11-11

    I'm really new at Ruby On Rails and I'm working with a baseApp that comes with the login and user registration functionalities. It also creates an empty profile for a user when they sign up. Then, I've created a migration to add fields to the profile

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.178 (s). 11 q(s)