Opened 19 years ago
Closed 17 years ago
#189 closed defect (fixed)
Inline editing of foreign keys doesn't do pretty error handling.
Reported by: | Nick Stenning | Owned by: | Adrian Holovaty |
---|---|---|---|
Component: | contrib.admin | Version: | |
Severity: | normal | Keywords: | admin interface error handling schema null fields |
Cc: | Triage Stage: | Ready for checkin | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
When adding/editing foreign keys in the admin interface, any violation of NOT NULL or other schema specifications will throw a traceback rather than a pretty "this is what you did wrong" explanation when adding foreign keys manually.
There's been an error: Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/django/core/handlers/base.py", line 63, in get_response return callback(request, **param_dict) File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/django/views/admin/main.py", line 860, in change_stage new_object = manipulator.save(new_data) File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/django/core/meta.py", line 87, in _curried return args[0](*(args[1:]+moreargs), **dict(kwargs.items() + morekwargs.items())) File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/django/core/meta.py", line 1479, in manipulator_save new_rel_obj.save() File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/django/core/meta.py", line 87, in _curried return args[0](*(args[1:]+moreargs), **dict(kwargs.items() + morekwargs.items())) File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/django/core/meta.py", line 765, in method_save (opts.db_table, ','.join(field_names), ','.join(placeholders)), db_values) File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/django/core/db/base.py", line 10, in execute result = self.cursor.execute(sql, params) IntegrityError: ERROR: null value in column "votes" violates not-null constraint INSERT INTO polls_choices (poll_id,choice,votes) VALUES ('1','This is making me hungry ;-)',NULL)
Change History (3)
comment:1 by , 19 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
comment:2 by , 19 years ago
Resolution: | invalid |
---|---|
Status: | closed → reopened |
Could we change the tutorial to contain either the 'blank=True' parameter or a warning that this will happen? The stack trace does not look like it was there by design and spoils the first impression a bit.
comment:3 by , 17 years ago
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
There is now a note in the model-api docs that describes what blank=True
does.
It's your responsibility to add
blank=True
to a field that hasnull=True
if you want the admin to complain about blank values.