#4733: Allowing blank inserts in models.Charfield
--------------------------+-------------------------------------------------
   Reporter:  Ceschiatti  |                Owner:  adrian    
     Status:  reopened    |            Component:  Validators
    Version:  SVN         |           Resolution:            
   Keywords:              |                Stage:  Unreviewed
  Has_patch:  0           |           Needs_docs:  0         
Needs_tests:  0           |   Needs_better_patch:  0         
--------------------------+-------------------------------------------------
Changes (by [EMAIL PROTECTED]):

  * status:  closed => reopened
  * resolution:  invalid =>

Comment:

 I have exactly the same beaviour on my model and consider it a serious bug
 to be honest. Here is how I can reproduce it.
 
 Here is my model I use. It even doesn't matter if I use blank=False on the
 name attribute.
 
 {{{
 class Project(models.Model):
   name        = models.CharField(_('Projektname'), max_length = 255)
   description = models.TextField(_('Beschreibung'), max_length = 64000,
 blank=True)
   active      = models.BooleanField(_('Aktiv?'), default = True)
   owner       = models.ForeignKey(User, verbose_name=_('Eigentümer'))
 
   class Meta:
     unique_together     = [('name', 'owner')]
     verbose_name        = _('Projekt')
     verbose_name_plural = _('Projekte')
     ordering            = ['name']
 
   class Admin:
     fields              = [(None, { 'fields': ('name', 'owner',
 'description', 'active') })]
     list_display        = ['owner', 'name', 'active']
     list_display_links  = ['name']
     list_filter         = ['active']
     search_fields       = ['name']
 
   def __unicode__(self):
     return self.name
 
 }}}
 
 And here is what I get in an interactive session.
 
 {{{
 >>> u = User.objects.get(username__exact="oa")
 >>> p = Project(owner = u)
 >>> p.validate()
 {'name': [u'This field is required.']}
 >>> p.save()
 }}}
 
 This must be an error in my eyes, cause it lets you insert invalid data
 into the database using the ORM, but prohibit it through the admin
 interface. And it can't also be DRY to actually require a call for
 validate before a save. At least that is, what I expect from it. ;)
 
 I am also using the SVN version of Django.

-- 
Ticket URL: <http://code.djangoproject.net/ticket/4733#comment:3>
Django Code <http://code.djangoproject.com/>
The web framework for perfectionists with deadlines
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django updates" 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-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to