Hello,

this is made possible by #6845 which is a Google Summer of Code
project for this year. You can check the progress at
http://code.djangoproject.com/browser/django/branches/soc2009/model-validation

Honza Král
E-Mail: [email protected]
Phone:  +420 606 678585



On Wed, Jul 1, 2009 at 1:16 PM, Bala kumar<[email protected]> wrote:
>
> Hi,
>
> Is it possible to apply validation on particular field within
> models.py?.
>
> I have the below model defined, the form is dynamically managed by
> Django Admin
>
> class CategoryMapping(models.Model):
>      categoryid   = models.AutoField(primary_key=True,)
>      categorytype = models.CharField( max_length = 250, unique =
> True,)
>      displayname  = models.CharField( max_length = 250, blank =
> False,)
>      description  = models.TextField( blank = True,)
>      def __str__(self):
>          return self.categorytype
>      class Meta:
>           db_table = 'category_mapping'
>
>
> Here I want to apply a validation for the field 'categorytype' in
> models.py itself without calling forms.py
>
> eg:
>
>  def clean_categorytype(self):
>        if self.cleaned_data.get('categorytype', 'test'):
>          raise forms.ValidationError(u'Please enter valid category
> type')
>        else:
>          return self.cleaned_data.get('categorytype')
>
> is it possible?
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to