On Thu, Oct 30, 2008 at 12:19 PM, [EMAIL PROTECTED] <
[EMAIL PROTECTED]> wrote:

>
> Ok, this sounds logical to me.
>
> I guess the best way to handle this is to make the uploading process
> require 2 separate submission pages, the first one for all the regular
> input, and then have a second page just to upload the file.
>
> Perhaps somebody has a better idea?
>

At the expense of some additional complexity in your view & template, you
can maintain a one-step submission for your users.  I'd probably look at
adding an additional hidden input field to the form that starts out empty
but is used in cases where a file has already been uploaded through a prior
submission which failed validation for some non-filefield-related problem.
The value in the hidden field would allow the server view code to locate the
previously-uploaded file when the form is re-submitted.  The template would
display the File input field only when necessary, if a file has already been
uploaded then the template would display a note to that effect instead.

So if there are no errors on the initial submission, it's a one-step process
for the user.

If there is an error (not related to the uploaded file), the server stashes
the uploaded file somewhere and sets the value of the hidden field so that
the file can be found on resubmit.  From a user's point of view the form is
redisplayed but they do not have to re-select the file -- rather the form
shows that the file has been uploaded and the other error messages on the
form show what needs to be corrected to complete the submission.

On resubmit, the server locates the previously-uploaded file via the
information in the hidden field instead of getting it from the post data.
Your view logic is a bit more complicated than for simple forms, and your
template has to be a little more involved than {{ form.as_p }}, but it's
probably more intuitive for users than a 2-step default submission process.

Karen

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to