#20205: positiveintegerfield null=True, blank=True
-------------------------------------+-------------------------------------
     Reporter:  anonymous            |                    Owner:  nobody
         Type:  Uncategorized        |                   Status:  new
    Component:  Database layer       |                  Version:  1.5
  (models, ORM)                      |               Resolution:
     Severity:  Normal               |             Triage Stage:
     Keywords:                       |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by bmispelon):

 * cc: bmispelon@… (added)
 * component:  Forms => Database layer (models, ORM)


Comment:

 The original report is not very clear, so here's a way to reproduce the
 error that the OP is refering to:
 {{{
 #!python
 # models.py
 from django.db import models

 class Foo(models.Model):
     bar = models.PositiveIntegerField(blank=True, null=True)

 # to reproduce:
 from django.core.exceptions import ValidationError
 foo = Foo(bar='')

 try:
     foo.full_clean()
 except ValidationError as error:
     print(error)
 else:
     foo.save()
 }}}

 Doing this, the model validation passes but the save throws an error:
 {{{
 ValueError: invalid literal for int() with base 10: ''
 }}}

 I would be inclined to mark this ticket as invalid, since it's incorrect
 to be passing an empty string as the value of an integer field, but
 there's some issues in this report that might still be relevant:

 * The model validation passes, which I find surprising (and might be
 another bug on its own)
 * The documentation (as far as I could find) does not mention what happens
 when you give incorrect data to models.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/20205#comment:2>
Django <https://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 unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to