|
List Info
Thread: Problem with URL
|
|
| Problem with URL |
  United States |
2007-06-27 03:55:45 |
Hi,
I'm having a problem here and I don't really know how to
solve it.
I have a form on a page, the add user page:
(r'^manager/operations/nlsciadc/users/adduser/$', add_user),
#The
template is add_user.html
When the user presses submit, the action on the form sends
the user
to:
<form name="form1" id="form1"
action="resultadd/" method="POST">
This on my urls.py call the view function result_add:
(r'^manager/operations/nlsciadc/users/adduser/resultadd/$',
result_add),
If an error occurs in the form, for example, the passwords
don't
match, the user is sent back to the add_user.html template:
if not form.is_valid():
return render_to_response('add_user.html',
{'form':form})
The problem is that when the user is sent back to the add
user page to
correct the errors, instead of going to the URL
manager/operations/
nlsciadc/users/adduser/ it remains in the URL
manager/operations/
nlsciadc/users/adduser/resultadd/ so when the user presses
the submit
button again the user is sent to the URL
/manager/operations/nlsciadc/
users/adduser/resultadd/resultadd/ which obviously isn't
mapped on the
urls.py file.
The only thing I can think of is telling the user to press
the back
button and fill the form again, but besides this being a
lame
solution, it's much better for the user to have the filled
form with
the errors next to each field and just having to correct
them, instead
of having to go back and fill the form.
I don't really know how to fix this. Is there anyway in the
view in
which I can call an URL in the http response? Anyone has any
ideas?
--~--~---------~--~----~------------~-------~--~----~
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 htt
p://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---
|
|
| Re: Problem with URL |
  United States |
2007-06-27 15:19:18 |
Hello,
On Jun 27, 10:55 am, AnaReis <anasofia_... hotmail.com> wrote:
> Hi,
> I'm having a problem here and I don't really know how
to solve it.
> I have a form on a page, the add user page:
> (r'^manager/operations/nlsciadc/users/adduser/$',
add_user), #The
> template is add_user.html
>
> When the user presses submit, the action on the form
sends the user
> to:
> <form name="form1" id="form1"
action="resultadd/" method="POST">
the best practice is to use the same view to display (GET
request) and
process (POST request) the form. This is shown here:
http://www.djangoproject.com/documentati
on/newforms/#simple-view-example
This way you redisplay the same page when the form is not
valid, and
redirect to another page upon successful form submission.
If something is not clear, feel free to ask again.
Bye,
Alberto
--~--~---------~--~----~------------~-------~--~----~
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 htt
p://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---
|
|
| Re: Problem with URL |
  United States |
2007-06-27 16:42:47 |
Yes, Alberto is right.
Also, I ran into this problem a few days ago. Basically,
after you
write your view processing like Alberto suggested, you need
to do a
response redirect or HttpResponseRedirect and pass it
"." (which is to
the same page the user was on). After I did that on my form,
the user
gets sent back to the same page and the "."
eliminates concatenating
another useradd string to the end of your url.
Have fun.
On Jun 27, 1:19 pm, Alberto Piai <alberto.p... gmail.com> wrote:
> Hello,
>
> On Jun 27, 10:55 am, AnaReis <anasofia_... hotmail.com> wrote:
>
> > Hi,
> > I'm having a problem here and I don't really know
how to solve it.
> > I have a form on a page, the add user page:
> > (r'^manager/operations/nlsciadc/users/adduser/$',
add_user), #The
> > template is add_user.html
>
> > When the user presses submit, the action on the
form sends the user
> > to:
> > <form name="form1"
id="form1" action="resultadd/"
method="POST">
>
> the best practice is to use the same view to display
(GET request) and
> process (POST request) the form. This is shown here:http://www.djangoproject.com/documentati
on/newforms/#simple-view-example
>
> This way you redisplay the same page when the form is
not valid, and
> redirect to another page upon successful form
submission.
>
> If something is not clear, feel free to ask again.
>
> Bye,
>
> Alberto
--~--~---------~--~----~------------~-------~--~----~
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 htt
p://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---
|
|
| Re: Problem with URL |
  United States |
2007-06-28 03:19:36 |
On Jun 27, 9:42 pm, robo <LongDay... gmail.com> wrote:
> Yes, Alberto is right.
>
> Also, I ran into this problem a few days ago.
Basically, after you
> write your view processing like Alberto suggested, you
need to do a
> response redirect or HttpResponseRedirect and pass it
"." (which is to
> the same page the user was on). After I did that on my
form, the user
> gets sent back to the same page and the "."
eliminates concatenating
> another useradd string to the end of your url.
>
> Have fun.
>
> On Jun 27, 1:19 pm, Alberto Piai <alberto.p... gmail.com> wrote:
>
> > Hello,
>
> > On Jun 27, 10:55 am, AnaReis <anasofia_... hotmail.com> wrote:
>
> > > Hi,
> > > I'm having a problem here and I don't really
know how to solve it.
> > > I have a form on a page, the add user page:
> > >
(r'^manager/operations/nlsciadc/users/adduser/$', add_user),
#The
> > > template is add_user.html
>
> > > When the user presses submit, the action on
the form sends the user
> > > to:
> > > <form name="form1"
id="form1" action="resultadd/"
method="POST">
>
> > the best practice is to use the same view to
display (GET request) and
> > process (POST request) the form. This is shown
here:http://www.djangoproject.com/documentati
on/newforms/#simple-view-example
>
> > This way you redisplay the same page when the form
is not valid, and
> > redirect to another page upon successful form
submission.
>
> > If something is not clear, feel free to ask
again.
>
> > Bye,
>
> > Alberto
Weee! I did it! Thanks guys
Ana
--~--~---------~--~----~------------~-------~--~----~
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 htt
p://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---
|
|
[1-4]
|
|