#9863: InlineModelAdmin breaks in the latest revision 9650
----------------------------------+-----------------------------------------
 Reporter:  shilin                |       Owner:  nobody    
   Status:  new                   |   Milestone:  post-1.0  
Component:  django.contrib.admin  |     Version:  SVN       
 Keywords:  admin                 |       Stage:  Unreviewed
Has_patch:  0                     |  
----------------------------------+-----------------------------------------
 I've defined two models like this:

 {{{

 class Parent(models.Model):
     name = models.CharField(max_length = 128, db_index = True)

 class Child(models.Model):
     parent = models.ForeignKey(Parent, related_name = 'child_set',
 editable = False)
     name = models.CharField(max_length = 30, blank = True)

 }}}

 And in admin.py, I tried to edit the Child object related to the certain
 Parent object.


 {{{

 class ChildInline(admin.StackedInline):
     model = Child
     extra = 10

 class ParentAdmin(admin.ModelAdmin):
     inlines = [
        ChildInline,
     ]

 site.register(Parent, ParentAdmin)

 }}}


 However, the admin application shows something like below:

 {{{
 KeyError at /admin/object/object/add/

 'object'
 }}}

 The line of code which throws the exception is

 {{{
 C:\Python24\lib\site-packages\django\forms\models.py in add_fields

  487. return save_instance(form, new_obj, exclude=[self._pk_field.name],
 commit=commit)
  488.
  489. def add_fields(self, form, index):
  490. super(BaseInlineFormSet, self).add_fields(form, index)
  491. if self._pk_field == self.fk:
  492. form.fields[self._pk_field.name] =
 InlineForeignKeyField(self.instance, pk_field=True)
  493. else:

  >>>This Line>>> 494. form.fields[self.fk.name] =
 InlineForeignKeyField(self.instance,
 label=form.fields[self.fk.name].label) ...

 }}}

 I've tried to revert my Django to revision 9160, the same model and admin
 settings do not throw the same exception. It's like that the foreignkey
 field leads to this error.
 But I'm quite confused about it.

-- 
Ticket URL: <http://code.djangoproject.com/ticket/9863>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to