Bones' Blog of Stuff About Things

01 Feb

More Toolbox Behaviour

I put aside an hour this evening to fix a few visual elements of the site, continue the cleaning out of the development directories and to add what I thought would be a five minute functionality addition — a simple radio button form to change the rendering output of the map between terrain type, water flow etc. This actually took forty five minutes, but only because I forgot about a gotcha I’ve mentioned before.

Here’s the form opener (without angled brackets, because WordPress gets upset if they’re there):

form action="/djangosite/game/updatemap" method="post" onsubmit="refresh_map();"

Looks fine, right? Except that no post values were getting through. The code was being called just fine, but the request.POST dictionary was empty. Here’s the working version:

form action="/djangosite/game/updatemap/" method="post" onsubmit="refresh_map();"

Notice the difference? Check out the addition of the trailing ‘/’ on the action. Now I’ve said before that I’m completely unskilled in the whole web programming arena, and I’m sure that this sort of thing just gets ingrained somewhere along the line, but right now I can’t help but feel that if the URL is good enough to get the right view method called, then surely the appropriate POST values should be coming with it too?

Or maybe I’m just a cretin.

Anyway, work was done, progress was made, as incremental as it may be.

2 Responses to “More Toolbox Behaviour”

  1. 1
    Wilson Says:

    The translation of djangosite/game/updatemap to /djangosite/game/updatemap/ is a redirect (since technically they’re two URLs, and each entity should really have one location), and POST values aren’t passed through the redirect.

    It’s burned me before, but it makes sense in the end.

  2. 2
    mwtb Says:

    Thanks for the explanation and for letting me know I wasn’t being uniquely stupid. It’s one of those things that I’m sure I’ll do again. I just hope I remember what caused it this time so I can avoid the wasted time looking for non-existent issues.

Leave a Reply

© 2012 Bones' Blog of Stuff About Things | Entries (RSS) and Comments (RSS)

GPS Reviews and news from GPS Gazettewordpress logo