Code

Opened 4 years ago

Closed 4 years ago

#14071 closed (wontfix)

Row duplicated when modifying PK

Reported by: mnbayazit Owned by: nobody
Component: contrib.admin Version: 1.2
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

Create a model and add a field with primary_key=True
Go into the django admin panel and change this primary key.
A new entry is added with the new PK, but the old one remains as well.

Sample model:

class FlatPage(Model):

title = CharField(max_length=50)
key = SlugField(max_length=50, primary_key=True, help_text="Do not change.")
content = TextField()
created = DateTimeField(auto_now_add=True)
updated = DateTimeField(auto_now=True)
def unicode(self):

return self.title

class Meta:

app_label = 'app'

Attachments (0)

Change History (1)

comment:1 in reply to: ↑ description Changed 4 years ago by SmileyChris

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to wontfix
  • Status changed from new to closed

Replying to mnbayazit:

Create a model and add a field with primary_key=True
Go into the django admin panel and change this primary key.
A new entry is added with the new PK, but the old one remains as well.

Sample model:

class FlatPage(Model):
    title = CharField(max_length=50)
    key = SlugField(max_length=50, primary_key=True, help_text="Do not change.")
    content = TextField()
    created = DateTimeField(auto_now_add=True)
    updated = DateTimeField(auto_now=True)
    def __unicode__(self):
	return self.title
    class Meta:
	app_label = 'app'

The primary key is exactly how the decision is made as to whether update or create a new row.

Altering this behavior would be a fundamentally backwards incompatible change.

Add Comment

Modify Ticket

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


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

 
Note: See TracTickets for help on using tickets.