Thursday, March 29, 2012

Re: Can I POST edit form to detail view, and redirect back if invalid?

On Thu, Mar 29, 2012 at 12:49 PM, Hemebond <hemebond@gmail.com> wrote:
> I don't see anything on there that deals with transferring an
> redirecting with POST data. Is there a particular section that covers
> this?
>
> To be honest, I'm not sure if HTTP really supports what I'm trying to
> do, let alone Django.
>

I think this is more accurate. You should try to sit within the
conventions used with HTTP in order to have a good experience.

You should present your form at a particular URI. If the form data is
valid, save the data, and redirect to a palce to view the data.

Eg,

» GET /widgets/create
« Django renders object creation form
* User fills in form
» POST /widgets/create
* Form is not valid
« Django renders bound object creation form, with errors highlighted
* User fills in form correctly
» POST /widgets/create
* Django creates object
« Django redirects user to /widgets/by-id/1
» GET /widgets/by-id/1
« Django renders object edit form

etc.

If you don't want to do it the standard way, there must be some
compelling reason. Care to share?

Cheers

Tom

--
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 django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment