HTML Forms without actions

In Django / Pinax, I've come across the login form which starts like this :

<form class="login" method="POST" action="">

It works perfectly well. So I assume that either some java-script or something in the Django framework is putting the value into the action attribute. So, my questions:

  • How does Django insert the action?
  • Why do they do it like this?
  • How can I find out what the action of this form is?

Update : I see this is not a Django thing at all, but what most browsers do.

Answers


Having an action of an empty string in most browsers points the form at the URL the browser currently has loaded, which is the script that served the form in the first place.


For an interesting insight on forms with empty actions read this thread, which gives you an updated HTML5-perspective on this matter.


It's also possible that javascript loaded with this page could be setting an action once the page is loaded based on what application is using the page.

Another likely possibility is that the javascript is handling the onsubmit event. One might do that to prevent the page from reloading or redirecting to a specific page


I guess it's bit late to answer this post. Anyways, I'll what I learnt about this.

If the "action" is not specified in forms, then the Django looks up the HttpResponseRedirect in the corresponding view.

For example, in the example below:

if form.is_valid(): # All validation rules pass
        # Process the data in form.cleaned_data
        # ...
        return HttpResponseRedirect('/thanks/')

Once, the form is validated (and processed), the page is redirected to 'thanks'


Need Your Help

Is it there any LRU implementation of IDictionary?

c# programming-languages caching

I would like to implement a simple in-memory LRU cache system and I was thinking about a solution based on an IDictionary implementation which could handle an hashed LRU mechanism.