Saturday, April 30, 2011

blank=True, null=True dont work with UserProfile

Hello friends, I have the following models,

the problem is that the fields null = True and blank = True,

are being validated when they should enter zero plumb, can someone help me?



class UserProfile(models.Model):
    sexo = models.CharField(choices=(("masculino","masculino"),("feminino","feminino")),max_length=100)
    cpf = models.CharField("Cpf", max_length=15,blank=False)
    telefone = models.CharField(max_length=100, blank=True, null=True)  <-- Here the problem
    celular = models.CharField("Celular",blank = True, null = True ,max_length=100)
    endereco = models.CharField(u"Endereço",max_length=100,blank=False)
    numero = models.CharField(u"Número",max_length=100,blank=False)
    complemento = models.CharField("Complemento",max_length=100,blank=True,null=True)
    bairro = models.CharField("Bairro",max_length=100,blank=False)
    cidade = models.CharField("Cidade",max_length=100,blank=False)
    estado = models.CharField("Estado",choices=UF_CHOICES,max_length=100)
    cep = models.CharField("Cep",max_length=100,blank=False)

    data_nascimento = models.DateField(blank=True,null=True,)
    saldoBid = models.IntegerField("Saldo de Bids",blank=True,null=True,default=5)
    user = models.OneToOneField(User, unique=True, primary_key=True, related_name='profile')
  

    def __unicode__(self):
        return self.user.first_name

def user_post_save(sender, instance, signal, *args, **kwargs):
    profile, new = UserProfile.objects.get_or_create(user=instance)

signals.post_save.connect(user_post_save, sender=User)

--
Daniel Corbe Hahne Latorre
daniel@corbe.com.br
55 48 9618-5115 
skype: daniel_corbe

--
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 django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment