Opened 9 years ago

Closed 7 years ago

#1603 closed defect (invalid)

Setting a primary key field editable=False breaks when using edit_inline

Reported by: anonymous Owned by: nobody
Component: contrib.admin Version: master
Severity: normal Keywords: edit_inline
Cc: david@… Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

Setting a primary key field editable=False breaks inline editing. Given the following models:

class FooOne(models.Model):
    id = models.AutoField(primary_key=True, editable=False)
    foobar = models.CharField(maxlength=24, core=True)
    class Admin:
        pass

    def __repr__(self):
        return self.foobar

class FooMany(models.Model):
    id = models.AutoField(primary_key=True, editable=False)
    foo = models.CharField(maxlength=24, core=True)
    fooone = models.ForeignKey(FooOne, edit_inline=models.TABULAR)
    class Admin:
        pass

    def __repr__(self):
        return self.foo

When attempting to update an added FooOne entry via the admin interface, The following error occurs:

Traceback (most recent call last):
File "/usr/lib/python2.4/site-packages/Django-0.91-py2.4.egg/django/core/handlers/base.py" in get_response
  73. response = callback(request, *callback_args, **callback_kwargs)
File "/usr/lib/python2.4/site-packages/Django-0.91-py2.4.egg/django/contrib/admin/views/decorators.py" in _checklogin
  54. return view_func(request, *args, **kwargs)
File "/usr/lib/python2.4/site-packages/Django-0.91-py2.4.egg/django/views/decorators/cache.py" in _wrapped_view_func
  40. response = view_func(request, *args, **kwargs)
File "/usr/lib/python2.4/site-packages/Django-0.91-py2.4.egg/django/contrib/admin/views/main.py" in change_stage
  328. new_object = manipulator.save(new_data)
File "/usr/lib/python2.4/site-packages/Django-0.91-py2.4.egg/django/db/models/manipulators.py" in save
  164. if rel_new_data[related.opts.pk.name][0]:

  KeyError at /admin/trak/fooone/1/
  'id'

The rel_new_data variable at this point contains:

{'foo': ['oof']}

Obviously, an 'id' key is expected. When I change the model of FooMany, so that the 'id' field is editable, I am able to update FooOne successfully via the admin interface.

Change History (4)

comment:1 Changed 8 years ago by Gary Wilson <gary.wilson@…>

  • Keywords editable removed
  • Summary changed from Setting a primary key field editable=False breaks inline editing. to Setting a primary key field editable=False breaks when using edit_inline
  • Triage Stage changed from Unreviewed to Accepted

changed summary to include "edit_inline". see also #2434.

comment:2 Changed 8 years ago by adrian

  • Version changed from magic-removal to SVN

comment:3 Changed 8 years ago by ubernostrum

#5693 was marked as a duplicate.

comment:4 Changed 7 years ago by brosner

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

This should be fixed in 1.0. Marking invalid now.

Note: See TracTickets for help on using tickets.
Back to Top