On 10/30/07, Milan Andric <[EMAIL PROTECTED]> wrote: > I'm writing an application form (allow people to apply for a workshop) > and we allow the applicant to submit unfinished applications because > they can return to complete them at a later date. So most of the > model fields are blank=True. Most of the fields are not required for > a save() but i'd like to toggle a complete flag when the right fields > have been submitted.
This is very interesting, and something I think could be handled fairly elegantly. > 1) A way to designate which fields determine the complete flag. I think required=True would still be your best bet here. I'll explain more in a moment on how this might work. > 2) Some mechanism to set this complete flag on save(). Well, kinda. Okay, time to explain. What it sounds like you need is a pend() method, which will store all the values in their current state, without validation. you must be very careful when doing this, of course, so that the pended values don't get used for anything except displaying the form again later. I assume you already have a model somewhere you plan to store the field's data, so just write a pend() method that does only that. You can then, if you like, offer users a "Pend" button which will call that method instead of save(). When they're complete, they would click "Save" (or whatever) and the save() method would do all the necessary validation and do what it's supposed to do with a complete form. An alternative, if you'd rather not have a separate "Pend" button, would be to process the form a little bit differently in the view when the user clicks "Save". For instance: if form.is_valid(): # The form is complete, so process it form.save() else: # Save the current values so the user # won't have to start all over again. form.pend() # But make sure to show the form again # with the errors, so the user can fix them Basically, you'd write pend() to take care of storing an in-progress form, and save() for processing a completed form. Then you have a couple options on deciding when to call which one. Also, I'll leave pulling up a pended form as an exercise for you. It shouldn't be that hard once you get the storage worked out. -Gul --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com 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 -~----------~----~----~----~------~----~------~--~---