Changes between Initial Version and Version 1 of Ticket #27720


Ignore:
Timestamp:
01/10/17 22:36:28 (6 years ago)
Author:
Tim Graham
Comment:

I'm not sure if a backwards-compatible solution is feasible. Objects created with the ORM assume the developer is doing things properly. If user input is incoming, then you can call Model.clean() to get a better error message. If someone has an idea of an improvement, feel free to reopen.

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #27720

    • Property Status changed from new to closed
    • Property Resolution changed from to needsinfo
    • Property Type changed from Uncategorized to Cleanup/optimization
    • Property Easy pickings unset
  • Ticket #27720 – Description

    initial v1  
    22
    33The example project says to instantiate a model in this way:
    4 q = Question(**question_text**="What's new?",** pub_date**=timezone.now())
     4`q = Question(question_text="What's new?", pub_date=timezone.now())`
    55
    66However, if you do something silly like not assigning attributes:
    7 q = Question("What's new?", timezone.now())
     7`q = Question("What's new?", timezone.now())`
    88
    99The model will still instantiate. What's super confusing is that if you forget to type in the attributes, then apply
    10 q.save()
     10`q.save()`
    1111
    12 You get the bizarre error ValueError: invalid literal for int() with base 10: 'Question'
     12You get the bizarre error `ValueError: invalid literal for int() with base 10: 'Question'`
    1313
    14 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.
     14If 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.
Back to Top