#27720: Confusing error message when creating a model with unspecified 
attributes
that have no defaults
-------------------------------------+-------------------------------------
               Reporter:  sanaani    |          Owner:  nobody
                   Type:             |         Status:  new
  Uncategorized                      |
              Component:  Database   |        Version:  1.10
  layer (models, ORM)                |
               Severity:  Normal     |       Keywords:  model
           Triage Stage:             |      Has patch:  0
  Unreviewed                         |
    Needs documentation:  0          |    Needs tests:  0
Patch needs improvement:  0          |  Easy pickings:  1
                  UI/UX:  0          |
-------------------------------------+-------------------------------------
 Using the example project at
 https://docs.djangoproject.com/en/1.10/intro/tutorial02/.

 The example project says to instantiate a model in this way:
 q = Question(**question_text**="What's new?",** pub_date**=timezone.now())

 However, if you do something silly like not assigning attributes:
 q = Question("What's new?", timezone.now())

 The model will still instantiate. What's super confusing is that if you
 forget to type in the attributes, then apply
 q.save()

 You get the bizarre error ValueError: invalid literal for int() with base
 10: 'Question'

 If a model object is created without an assigned attribute and the missing
 attribute has no default specified, then some type of warning should
 appear. I wasted about 3 hours today figuring out this dumb mistake; the
 error message isn''t related to the initial error.

--
Ticket URL: <https://code.djangoproject.com/ticket/27720>
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/050.2206f3f1df74784f1a2a8dd7680b5017%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to