Code

Opened 9 years ago

Closed 9 years ago

Last modified 7 years ago

#482 closed defect (invalid)

ForeignKey inline editing drops records in the Admin application

Reported by: brovienas@… Owned by: adrian
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: UI/UX:

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

Attachments (0)

Change History (2)

comment:1 Changed 9 years ago by jacob

  • Resolution set to invalid
  • Status changed from new to closed

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 Changed 7 years ago by anonymous

  • Component changed from Admin interface to Cache system
  • Triage Stage changed from Unreviewed to Accepted

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.