Opened 9 years ago

Closed 9 years ago

#6622 closed (invalid)

Model with edit_inline on parent Model doesn't get saved on parent Model save

Reported by: panni@… Owned by: nobody
Component: contrib.admin Version: master
Severity: Keywords: edit_inline, admin, not saved
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


Assuming we're having the following constellation:

class model_a(models.Model):
  cf = models.CharField("x", null=True, blank=True)
  def save(self):

  class Admin:

class model_b(models.Model):
  cf = models.CharField("y", null=True, blank=True)
  reftox = models.ForeignKey(another_model, ...)
  reftoa = models.ForeignKey(model_a, verbose_name="A", related_name="BtoA", edit_inline=models.TABULAR, num_in_admin=3, num_extra_on_change=3, core=True)

  def __unicode__(self):
    if self.reftox:
      return u"%s, %s" % (self.reftox, self.reftoa.somefield)
      return u"%s, %s" % (, self.reftoa.somefield)

  class Admin:

  class Meta:

When saving model_a in Django Admin any filled model_b won't be saved on save. doesn't even get called.

This seems to be some issue with the resolving of unicode's reference to model_a.

Change History (2)

comment:1 Changed 9 years ago by panni@…

Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset

This can be fixed by removing "core=True" on model_b reference to model_a, and adding it to
Also unicode seems to be needed to be rewritten like:

  def __unicode__(self):
    if self.reftoa:
      if self.reftox:
        return u"%s, %s" % (self.reftox, self.reftoa.somefield)
        return u"%s, %s" % (, self.reftoa.somefield)
    return "Blah"

comment:2 Changed 9 years ago by Honza Král

Resolution: invalid
Status: newclosed

Closing this ticket since its deprecated with newforms-admin. Handling of edit_inline is rewrtitten from scratch there...

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