Opened 11 years ago

Closed 11 years ago

Last modified 10 years ago

#320 closed defect (fixed)

After completing Tutorial 2, there appears to be a bug in the foreign key related default admin code

Reported by: Steve Steiner Owned by: Adrian Holovaty
Component: contrib.admin Version: 1.0
Severity: major Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

When I've gotten through the tutorial and have the Poll/Choice window
working with the Poll above and the choices below, I see what looks to me like a big bug.

Pressing "Save and continue editing" adds a new Poll with the exact
same Question but a new ID. When the screen refreshes, the Choices
section is empty since we're now looking at the new, erroneously
created Poll.

I'm using MySQL if that's important.

Change History (8)

comment:1 Changed 11 years ago by Adrian Holovaty

Try updating your Django code and giving it another shot.

comment:2 Changed 11 years ago by Steve Steiner

I refreshed from SVN to version 494 (from 493) and am experiencing exactly the same problem.

comment:3 Changed 11 years ago by Adrian Holovaty

Give revision [497] a shot and report back, if you could. :)

comment:4 Changed 11 years ago by Steve Steiner

Identical behaviour.

comment:5 Changed 11 years ago by jbennett@…

I'm seeing the same problem on a weblog model I'm building; entries have comments which are related to them via a ForeignKey, and editing an existing entry instead creates a new one. Even worse, it doesn't seem to be doing any validation when it creates the new entry, because it's violating a unique_for_date requirement on various metadata. I'm on revision 494 (will update in a moment and see if it persists), using MySQL 4.0.23.

comment:6 Changed 11 years ago by Steve Steiner

Ticket 323 seems to be a simplification of this issue though the validation issue is, obviously, separate.

comment:7 Changed 11 years ago by Adrian Holovaty

Status: newassigned

#323 is indeed a duplicate. I've added a unit test for this in [506].

comment:8 Changed 11 years ago by Adrian Holovaty

Resolution: fixed
Status: assignedclosed

(In [507]) Fixed #320 -- Changed save() code so that it doesn't rely on cursor.rowcount. MySQLdb sets cursor.rowcount to 0 in an UPDATE statement even if the record already exists. Now save() does a SELECT query to find out whether a record with the primary key already exists.

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