Web Images Videos Maps News Shopping Gmail more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Validation within models.py
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  2 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Bala kumar  
View profile  
 More options Jul 1, 7:16 am
From: Bala kumar <kumarba...@gmail.com>
Date: Wed, 1 Jul 2009 04:16:18 -0700 (PDT)
Local: Wed, Jul 1 2009 7:16 am
Subject: Validation within models.py
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?


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Honza Krįl  
View profile  
 More options Jul 2, 11:19 am
From: Honza Krįl <honza.k...@gmail.com>
Date: Thu, 2 Jul 2009 17:19:58 +0200
Local: Thurs, Jul 2 2009 11:19 am
Subject: Re: Validation within models.py
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-v...

Honza Krįl
E-Mail: Honza.K...@gmail.com
Phone:  +420 606 678585


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google