django - urlconf request mapping and views not reached

i have a form in a template, but it can't reach the correspondant view. the method is GET. i've tried also to pass it an argument just to populate the query string, but the request doesnt reach the mapped view. here'sthe views.py, urls.py and the template:

template.html

<div id="search-new-btn">
    <form action="/anagrafica/new/" method="get">
        <input type="submit" title="Crea nuovo soggetto anagrafica" value="Nuovo" />
    </form>
</div>

views.py

def anagrafica_new(request):

    if request.method == 'GET':      
        form = AnagraficaForm()
        sub = 'Nuovo soggetto anagrafica'
        dict = {'sub':sub,'form':form}
        return render_to_response('anagrafica_form.html', dict, context_instance=RequestContext(request))

urls.py

...
url(r'^anagrafica/new/',('gpf1.views.anagrafica_new')),
...

(http://openpaste.org/05b157c1)

Anyway, i've also tried to remove the () from the callback url.py mapping, but it didnt change nothing. the request seems to be mapped cause my debug server print this:

"GET /anagrafica/new/? HTTP/1.1" 200 17310

but nothing more. the browser remain on the same page; i also put a print statement just inside the view but it never has been reached. any idea?

thanks, Luke

Answers


As Willian suggested don't put the view in a tuple. Another thing you are missing is the $ at the end of regular expression i.e.:

urls.py

...
url(r'^anagrafica/$','gpf1.views.anagrafica'),
...
url(r'^anagrafica/new/$','gpf1.views.anagrafica_new'),
...

Make sure that the folder containing gpf1 package is within Pythonpath variable (reachable by python).

Edit: Subsequently I noticed you have a root url map for

url(r'^anagrafica/','gpf1.views.anagrafica')

Since you are missing $ at the end Django will try to map anagrafica/anything here to gpf1.views.anagrafica which is probably not what you want. Consider rereading regular expressions and Django's url mapping documentation as it will make things a bit clearer.


Need Your Help

Is there a better way to write this jQuery script?

javascript jquery html css shortcut

So the script works, but it seems pretty long. I think there may be some shortcuts I could take, maybe use an array? But I'm new at JS, and really new at jQuery.

Facebook Applications

facebook

I just wanted to know if there is a way to host a facebook application in facebook's servers and not elsewhere. is facebook providing hoting for applications?