def test_attrs_can_be_specified_per_field(self):
     widget = DateOfBirthWidget(
         attrs={'data-foo': 'bar'},
         day_attrs={'data-type': 'day'},
         month_attrs={'data-type': 'month'},
         year_attrs={'data-type': 'year'},
     )
     self.assertEqual(
         widget.render('date_of_birth', None),
         u'<input data-foo="bar" data-type="day" max="31" min="1" name="date_of_birth_0" placeholder="DD" type="number" />'
         u'<input data-foo="bar" data-type="month" max="12" min="1" name="date_of_birth_1" placeholder="MM" type="number" />'
         u'<input data-foo="bar" data-type="year" max="9999" min="1" name="date_of_birth_2" placeholder="YYYY" type="number" />'
     )
 def test_attrs_can_be_specified_per_field(self):
     widget = DateOfBirthWidget(
         attrs={'data-foo': 'bar'},
         day_attrs={'data-type': 'day'},
         month_attrs={'data-type': 'month'},
         year_attrs={'data-type': 'year'},
     )
     self.assertEqual(
         widget.render('date_of_birth', None),
         u'<input data-foo="bar" data-type="day" max="31" min="1" name="date_of_birth_0" placeholder="DD" type="number" />'
         u'<input data-foo="bar" data-type="month" max="12" min="1" name="date_of_birth_1" placeholder="MM" type="number" />'
         u'<input data-foo="bar" data-type="year" max="9999" min="1" name="date_of_birth_2" placeholder="YYYY" type="number" />'
     )
Example #3
0
 class Meta:
     model = Profile
     fields = ['first_name', 'last_name', 'dob', 'image', 'country']
     widgets = {
         'country': CountrySelectWidget(),
         'dob': DateOfBirthWidget(),
     }
Example #4
0
 class Meta(UserCreationForm.Meta):
     model = CustomUser
     fields = ('username', 'email', 'first_name', 'last_name', 'phone',
               'birth_date')
     widgets = {
         'birth_date': DateOfBirthWidget(order='MDY'),
     }
Example #5
0
 class Meta:
     model = Voter
     fields = ("email", "first_name", "last_name", 'phone', 'date_of_birth',
               'address', 'city', 'state', 'zipcode')
     widgets = {
         'date_of_birth': DateOfBirthWidget(),
     }
Example #6
0
 class Meta:
     model = Profile
     fields = ['title', 'image', 'address_line_1', 'address_line_2', 'street_address', 'country', 'summary',
               'gender', 'gender', 'date_of_birth', 'phone']
     widgets = {
         'date_of_birth': DateOfBirthWidget(),
     }
Example #7
0
 class Meta:
     model = Teen
     fields = ['firstname','lastname','othername','email','gender','dob','age',
                 'phone','school','level','cclass','address','ambition','bornagain','hobbies']
     widgets = {
         'dob': DateOfBirthWidget(),
     }
     
Example #8
0
 class Meta:
     model = profile
     fields = [
         'fname', 'lname', 'date_of_birth', 'email', 'display_picture'
     ]
     widgets = {
         'date_of_birth': DateOfBirthWidget(),
     }
Example #9
0
 class Meta:
     model = Tourist
     fields = (
         'first_name',
         'last_name',
         'birth_date',
         'sex',
         'country',
         "username",
         'email',
     )
     widgets = {
         'birth_date': DateOfBirthWidget(),
     }
Example #10
0
    class Meta:
        model = Client
        fields = "__all__"

        labels = {
            'fullname': 'Your name',
            'sum_insured': 'Sum Insured',
            'dob': 'Date of Birth',
            'policy_type': 'Policy Type'
        }

        widgets = {
            'dob': DateOfBirthWidget(),
        }
 def test_partial_options_disallowed(self):
     with pytest.raises(ValueError):
         DateOfBirthWidget(order='YM')
 def test_lowercase_disallowed(self):
     with pytest.raises(ValueError):
         DateOfBirthWidget(order='Ymd')
 def test_invalid_options_disallowed(self):
     with pytest.raises(ValueError):
         DateOfBirthWidget(order='YMZ')
 def test_duplicate_order_elements_disallowed(self):
     with pytest.raises(ValueError):
         DateOfBirthWidget(order='YYMD')
         DateOfBirthWidget(order='YYD')
Example #15
0
 class Meta(object):
     model = Person
     fields = ['name', 'date_of_birth']
     widgets = {
         'date_of_birth': DateOfBirthWidget(order='YMD'),
     }
Example #16
0
 class Meta:
     model = Teen
     fields = ['firstname', 'lastname', 'dob']
     widgets = {
         'dob': DateOfBirthWidget(),
     }