Hi, im getting ValueError when try to redirect to an html page.. also
the validation code in forms.py doesnt work when i test it with wrong
inputs. it accepts the wrong input also.. what would be the bug?
===views.py code==
def register(request):
        if request.method == 'POST':
                form = form_register(request.POST)
                if form.is_valid():
                        reg = loginform( usr_name = 
form.cleaned_data['usr_name'], pswd =
form.cleaned_data['pswd'])
                        reg.save()
                        return HttpResponseRedirect('/index/')
        #return render_to_response('thanks.html')
        else:
                form = form_register()
                variables = RequestContext(request, {'form':form})
                return render_to_response('register.html',variables)
--------------------------------------------
===forms.py code===
class form_register(forms.Form):
        usr_name = forms.CharField(label='Enter your user
name:',max_length=50)
        pswd = forms.CharField(label='Password:',widget=forms.PasswordInput
(render_value=False))
        def clean_usr_name(self):
                usr_name = self.cleaned_data['usr_name']
                if not re.search(r'^\w+$',usr_name):
                        raise forms.ValidationError('Username can only contain 
alphanumeric
characters and the underscore.')
                return usr_name
------------------------------
===urls.py code===

urlpatterns = patterns('',(r'^$',index),(r'^register/$',register),
(r'^login/$',login),(r'^index/$',index),(r'^logout/$',logout_page),
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to