Opened 6 years ago

Closed 5 years ago

Last modified 3 years ago

#9693 closed (worksforme)

Custom don't change relational data when editing via admin (probably any other forms too)

Reported by: anonymous Owned by: nobody
Component: Forms Version: 1.0
Severity: Keywords:
Cc: dgouldin@… Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


Consider following models:

class A(models.Model):
    name = models.CharField(max_length = 100)

class B(models.Model):
    name = models.CharField(max_length = 100)
    related = models.ForeignKey(to = A, null = True, blank = True)

    def save(self):
        if not'@'):
   = '@' + # this will work always
        if self.related and'@'):
            self.related = None # won't work when editing via admin form
        super(B, self).save()

This illustrates that submitting the data via admin interface will always override relational changes in the custom method. Other fields, however, are changed as expected.

Calling save() under some other circumstances will always change relational data as expected.

Any glue how to fix it? Thanks.

Attachments (0)

Change History (5)

comment:1 Changed 6 years ago by anonymous

  • Component changed from Uncategorized to Forms
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

comment:2 Changed 5 years ago by jacob

  • milestone set to 1.1
  • Triage Stage changed from Unreviewed to Accepted

comment:3 Changed 5 years ago by dgouldin

  • Cc dgouldin@… added

I could not reproduce this behavior. Can anybody else?

comment:4 Changed 5 years ago by jkocherhans

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

I'm not able to duplicate this either. Please reopen with more details if this is still happening.

comment:5 Changed 3 years ago by jacob

  • milestone 1.1 deleted

Milestone 1.1 deleted

Add Comment

Modify Ticket

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

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

Note: See TracTickets for help on using tickets.