Here's a bit of the testing I have run in the shell...
>>> from mysite2.profile.models import Profile >>> from django import newformms >>> from mysite2.admin import ProfileOptions >>> >>> # instantiate a Profile object >>> test_profile = Profile.objects.get(id=1) >>> >>> # instantiate the adminoptions class >>> # used by the admin site >>> options = ProfileOptions(Profile) >>> >>> # create a form class for the profile instance >>> form = newforms.form_for_instance(test_profile,formfield_callback = >>> options.formfield_for_dbfield) >>> form <class 'django.newforms.models.ProfileInstanceForm'> >>> >>> # check that the zip_code field is of type ZipCodeField >>> form.base_fields['zip_code'] <mysite2.admin.ZipCodeField object at 0x1385dd0> >>> >>> # in my database, i currently have only one zip code >>> # 90069, with a key of 1. >>> >>> form.base_fields['zip_code'].initial 1 >>> >>> form.base_fields['zip_code'].clean(value='90069') 1 >>> >>> form.base_fields['zip_code'].clean(value='111') Traceback (most recent call last): File "<console>", line 1, in ? File "Sites/Django/mysite2/../mysite2/admin.py", line 40, in clean raise ValidationError, "Please enter a valid zip code." ValidationError: [u'Please enter a valid zip code.'] >>> >>> form.base_fields['zip_code'].clean(value='') Traceback (most recent call last): File "<console>", line 1, in ? File "/Users/leifstrickland/Sites/DjangoProject/mysite2/../mysite2/ admin.py", line 40, in clean raise ValidationError, "Please enter a valid zip code." ValidationError: [u'Please enter a valid zip code.'] >>> >>> zip_code_field = form.base_fields['zip_code'] >>> zip_code_field.widget.render(name='zip_code',value=1) u'<input type="text" name="zip_code" value="90069" />' >>> >>> zip_code_field.widget.render(name='zip_code',value='') u'<input type="text" name="zip_code" />' As you can see, everything seems to be working. I'm so puzzled... --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---