In the tutorial, the form action in the poll_detail template is
hardcoded to "/polls/..."

So the browser is doing what's been explicitly asked of it, despite
Django doing its best to deal gracefully with your mounting the app
at /mysite.

In my own newcomer approach, the way I found to work around this is to
pass in the script name into the context that goes to the template in
the render_to_response line of the view

'script_name':request.META['SCRIPT_NAME']

and then use that in the form action URL:

<form action="{{ script_name }}/polls/{{ object.id }}/vote/"
method="post">

This proobably means a // in the URL if you mount your site at /, but
I think most browsers and servers won't care about that extra /

I welcome anyone pointing out a better way to make the form action
more "portable" in projects...

-Preston

On Jan 17, 7:53 pm, Adam Yee <adamj...@gmail.com> wrote:
> It was a slam dunk for completing the tutorial in the development
> server, but I can't figure out this issue I'm having with the generic
> views while using my apache server.  I'm unable to get the vote view
> to redirect correctly.
>
> My apache error seen here with both urls.py and views.py.  The apache
> config is at the bottom.
>
> http://dpaste.com/110275/
>
> Voting (hiting the vote button) with or without a radio button
> selected is redirecting me tohttp://127.0.0.1/polls/1/vote/which
> gives me a 404 (and not in django's debug format) instead of ...mysite/
> polls/1/vote/.
>
> However, going in the backdoor way and manually typing 
> inhttp://127.0.0.1/mysite/polls/1/vote/takes me through the vote view
> KeyError exception saying "You didn't select a choice" and displays
> the page.  I'm also able to access the results URL manually.  So I'm
> thinking the problem lies in either the views.py, my urlconfs or
> something with my wsgi apache config.
>
> Can anyone see what I'm missing?
--~--~---------~--~----~------------~-------~--~----~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to