Hi everyone,

I added django registration to my app and i'm facing a problem with date
validation.
In my settings.py I have this :

DATE_INPUT_FORMATS = ('%Y-%m-%d', '%m/%d/%Y', '%m/%d/%y', '%b %d %Y',
'%b %d, %Y', '%d %b %Y', '%d %b, %Y', '%B % d %Y',
'%B %d, %Y', '%d %B %Y', '%d %B, %Y')
USE_L10N = True
USE_I18N = True
TIME_ZONE = 'Europe/Paris'
LANGUAGE_CODE = 'fr-FR'

I added a date field in my form.
ex :

from django import forms
from models import UserProfile
from captcha.fields import CaptchaField

from registration.forms import RegistrationForm

class ProfileForm(forms.Form):

    birthday = forms.DateField()
    country = forms.CharField()
    city = forms.CharField()
    addr1 = forms.CharField()

    def save(self, user):
        try:
            data = user.get_profile()
        except:
            data = UserProfile(user=user)

        data.city = self.cleaned_data["city"]
        data.birthday = self.cleaned_data["birthday"]
        data.country = self.cleaned_data["country"]
        data.addr1 = self.cleaned_data["addr1"]
        data.save()

class UserRegistrationForm(RegistrationForm):
    birthday = forms.DateField()
    country = forms.CharField()
    city = forms.CharField()
    addr1 = forms.CharField()
    captcha = CaptchaField()


The problem is when I submit this form with a date like 'dd/mm/YYYY' I met
this error :

ValidationError at /accounts/register/
[u'Saisissez une date valide au format AAAA-MM-JJ.']
Traceback:
File "/usr/local/lib/python2.6/dist-packages/django/core/handlers/base.py"
in get_response
  111.                         response = callback(request, *callback_args,
**callback_kwargs)
File "/usr/local/lib/python2.6/dist-packages/registration/views.py" in
register
  187.             new_user = backend.register(request, **form.cleaned_data)
File
"/usr/local/lib/python2.6/dist-packages/registration/backends/default/__init__.py"
in register
  82.                                      request=request)
File "/usr/local/lib/python2.6/dist-packages/django/dispatch/dispatcher.py"
in send
  172.             response = receiver(signal=self, sender=sender, **named)
File
"/home/projets/perso/myApp/alpha/myApp/../myApp/myAppFront/regbackend.py"
in user_created
  10.     data.save()


Do i have to conf the date input format of django registration ?
In order to test my date_input_format conf, i created an empty form with
one dateField, i submited it and print the cleaned_data value.
Every time I typed something like 'dd/mm/YYYY' it worked well in my new
form, but fail in my register form.

Do anyone have ever faced this kind of issues ?

Thx for your help :)

Regards
Nicolas

-- 
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