[BangPypers] Django URLs -> New URLs are getting appended with the previous one

Hussain Bohra hussainbohra_30 at yahoo.com
Thu Dec 18 11:44:43 CET 2008

Hi All,

I am trying my hands in a Django with a small application,  I am making one login page and acceptance / failure of a user name and password.

My functions for same:

How Submit button is Contructing 
def SubmitButton()
    return  '<INPUT TYPE="BUTTON" NAME="%s" VALUE="%s"  %s;>' % (self.name, self.label)


from django.http import HttpResponse
from html_tags import *
def loginPage(request) :
    title = ('Hi, Welcome ',"")
    text1 = ("Enter Your Name", "%s"%(toHTML(TextField('name'))))
    text2 = ("Enter Your Password","%s"%(toHTML(TextField('password',type='password'))))
    buttons = (toHTML(SubmitButton('init','Login')),CloseButton('Close'))
    content = toHTML(
    ret = '<FORM NAME="contentForm" method=GET enctype="multipart/form-data">'
    ret += content 
    ret += '</FORM>'
    return HttpResponse(ret)

def initialize(request):    
    get = request.GET.__copy__()
    name = smart_str(get.pop('name')[0])
    password = smart_str(get.pop('password')[0])
    ret = '<FORM NAME="contentForm" method=GET enctype="multipart/form-data">'
    #request.META.update({'HTTP_REFERER' : ''})
    if name == 'hussain.bohra' and password == 'password' :
        ret += toHTML(
                       Table([('Authorization Successful.',""),
                       ('You can further proceed',"")
    else :  
        ret += toHTML(
                        Table([('Authorization Failed.',""),
    ret += '</FORM>'
    return HttpResponse(ret)

and I have mapped a url with these functions, in a url.py file for Django Project.
    (r'^init/$', 'myproject.views.initialize'),
    (r'^login/$', 'myproject.views.loginPage'),

The problem I am facing here is when I am accessing my loginPage function will get called, if I do a submit, url trying to open is .... instead of, in that case I have to map /login/init with my initialize function instead of /init and if from  I want to back to login page using my button, url appears as, i.e. all the previous url it is keeping.

but if I make my own webserver (override do_GET and do_POST function), there my self.path (which contains URL), is coming properly, i.e. /login, /init .... 

In Django, also I able to fix the same by making a small change in 'C:\Python25\Lib\site-packages\django\core\handlers\wsgi.py' file by splitting the url and by getting the last instance and by putting in self.path. But this is not a right way to do the same, is any one know what else can be done for the same, so that the urls should not carry forward. I tried changing the request.META.['PATH_INFO'] = u'/', in my functions, but this also doesn't able to solve the issue.

Thanks and Regards,
Hussain Bohra

      Add more friends to your messenger and enjoy! Go to http://messenger.yahoo.com/invite/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/bangpypers/attachments/20081218/471d4368/attachment-0001.htm>

More information about the BangPypers mailing list