Opened 19 years ago

Closed 19 years ago

Last modified 17 years ago

#482 closed defect (invalid)

ForeignKey inline editing drops records in the Admin application

Reported by: brovienas@… Owned by: Adrian Holovaty
Component: Core (Cache system) Version:
Severity: normal Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I am using the ForeignKey with inline editing.

  1. I have opened the admin editor tp modify an existing parent record
  2. I have added an entry to child record
  3. Saved
  4. Go to edit the parent record
  5. I now have 2 places to enter the data. The first one is populated with previous data. The second one is empty.
  6. I click save
  7. I get the exception as displayed below
  8. 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")

Change History (2)

comment:1 by Jacob, 19 years ago

Resolution: invalid
Status: newclosed

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.)

comment:2 by anonymous, 17 years ago

Component: Admin interfaceCache system
Triage Stage: UnreviewedAccepted
Note: See TracTickets for help on using tickets.
Back to Top