Tuesday, 15 July 2014

Python-Django: Cannot find template -



Python-Django: Cannot find template -

i new python , django , have been trying larn how create registration form website. next tutorial https://www.youtube.com/watch?v=tam4igrpesg. have working point of registration_success page. here think relevant code:

settings.py

template_dirs = ( template_path + '/templates/', template_path + '/templates/registration', )

urls.py

#registration (r'^register/$', register_user), (r'^registration_success/$', registration_success),

views.py

def register_user(request): if request.method == 'post': form = usercreationform(request.post) if form.is_valid(): form.save() homecoming httpresponseredirect('registration_success') args = {} args.update(csrf(request)) print (args) args['form'] = usercreationform() homecoming render_to_response('register.html',args) def registration_success(request): homecoming render_to_response('registration_success.html')

the error getting this:

page not found (404) request method: request url: http://localhost:8000/register/registration_success using urlconf defined in tut_1.urls, django tried these url patterns, in order: ^$ ^login/$ ^logout/$ ^register/$ ^registration_success/$ ^portal/ ^static/(?p<path>.*)$ current url, registration/registration_success, didn't match of these.

i not sure going on tbh. did notice url is: http: / / localhost:8000/register/registration_success. why register/registration_...? should not registration/registration_success?

thanks in advance.

return httpresponseredirect('registration_success')

you redirecting path relative current url. explains why beingness routed /register/registration_success.

to solve this, need utilize root-relative path

return httpresponseredirect('/registration_success/')

python django templates url

No comments:

Post a Comment