On 7 Lut, 09:58, Mackenzie Kearl <[EMAIL PROTECTED]>
wrote:
> I am having trouble finding documentation on how to add custom
> validation to a custom model field.
>
> example:
>
> class PostalField(models.CharField):
>         def __init__(self,*args,**kwargs):
>                 kwargs['max_length']= 6
>                 super(PostalField, self).__init__(*args, **kwargs)
>
>         def get_internal_type(self):
>                 return "CharField"
>
Seems that you're mixing two types of fields here: fields from
django.db.models and fields from django.newforms.fields.
For this kind of validation (with postal code) you should create
custom newforms field or write custom validator for a form.
This is described at newforms documentation.

HTH

--
Maciej Wisniowski
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to