I am using the ForeignKey
with inline editing.
- I have opened the admin editor tp modify an existing parent record
- I have added an entry to child record
- Saved
- Go to edit the parent record
- I now have 2 places to enter the data. The first one is populated with previous data. The second one is empty.
- I click save
- I get the exception as displayed below
- If I go back and refresh the parent record view - it does not contain any child entries anymore.
class Lankymas(meta.Model):
nuo = meta.DateField(blank=True)
iki = meta.DateField(blank=True, null=True)
moksleivis = meta.ForeignKey(Moksleivis, edit_inline=meta.STACKED, num_in_admin=1)
class META:
module_name='lankymai'
def __repr__(self):
return "Nuo %s iki %s" % (self.nuo, self.iki)
There's been an error:
Traceback (most recent call last):
File "/usr/lib/python2.3/site-packages/django/core/handlers/base.py", line 64, in get_response
response = callback(request, **param_dict)
File "/usr/lib/python2.3/site-packages/django/views/admin/main.py", line 878, in change_stage
new_object = manipulator.save(new_data)
File "/usr/lib/python2.3/site-packages/django/utils/functional.py", line 3, in _curried
return args[0](*(args[1:]+moreargs), **dict(kwargs.items() + morekwargs.items()))
File "/usr/lib/python2.3/site-packages/django/core/meta/__init__.py", line 1549, in manipulator_save
new_rel_obj.save()
File "/usr/lib/python2.3/site-packages/django/utils/functional.py", line 3, in _curried
return args[0](*(args[1:]+moreargs), **dict(kwargs.items() + morekwargs.items()))
File "/usr/lib/python2.3/site-packages/django/core/meta/__init__.py", line 801, in method_save
','.join(field_names), ','.join(placeholders)), db_values)
File "/usr/lib/python2.3/site-packages/django/core/db/base.py", line 10, in execute
result = self.cursor.execute(sql, params)
File "/usr/lib/python2.3/site-packages/MySQLdb/cursors.py", line 137, in execute
self.errorhandler(self, exc, value)
File "/usr/lib/python2.3/site-packages/MySQLdb/connections.py", line 33, in defaulterrorhandler
raise errorclass, errorvalue
OperationalError: (1048, "Column 'nuo' cannot be null")
From http://www.djangoproject.com/documentation/model_api/#general-field-options: "It is an error to have an inline-editable relation without at least one core=True field."
(
django-admin validate
will also catch this error.)