Django

Code

Ticket #1603 (closed: invalid)

Opened 3 years ago

Last modified 3 months ago

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

Reported by: anonymous Assigned to: nobody
Milestone: Component: django.contrib.admin
Version: SVN Keywords: edit_inline
Cc: david@zettazebra.com Triage Stage: Accepted
Has patch: 0 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

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.

Attachments

Change History

02/17/07 22:33:58 changed by Gary Wilson <gary.wilson@gmail.com>

  • keywords changed from edit_inline editable to edit_inline.
  • 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.
  • stage changed from Unreviewed to Accepted.

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

06/07/07 16:57:02 changed by adrian

  • version changed from magic-removal to SVN.

10/06/07 17:01:46 changed by ubernostrum

#5693 was marked as a duplicate.

09/05/08 19:22:46 changed by brosner

  • status changed from new to closed.
  • resolution set to invalid.

This should be fixed in 1.0. Marking invalid now.


Add/Change #1603 (Setting a primary key field editable=False breaks when using edit_inline)




Change Properties
Action