On Jan 18, 7:39 am, ptone <pres...@ptone.com> wrote:
> 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">

Preston, thanks for pointing this out.  You're right about the url
being hardcoded and the prefix not being passed.  I played around with
your request.META['SCRIPT_NAME'] suggestion.  I can't figure out how
to pass the initial 'script_name' to the poll_detail before trying to
vote.  In other words, it seems like I would need to include
'script_name' in the context passed to the generic view
(object_detail) before it can properly be used in the form.

If I add an {% if script_name %} in the poll_detail template or just a
{{ script_name }}, it would need to be rendered before accessing the
vote view.  Maybe you can ellaborate on your method of getting django
to recognize the prefix.  Portability is looking difficult at this
point.  Thanks to all for your help.

>
> 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/takesme 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?- Hide quoted text -
>
> - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
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