Opened 18 years ago

Closed 18 years ago

Last modified 18 years ago

#2500 closed defect (fixed)

[patch] admin popup window stays open after adding and saving an item that has a primary_key=True field

Reported by: Gary Wilson <gary.wilson@…> Owned by: Adrian Holovaty
Component: contrib.admin Version: dev
Severity: normal Keywords:
Cc: gary.wilson@… Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I have the models:

class Semester(models.Model):
    name = models.CharField(maxlength=20, primary_key=True)

class Course(models.Model):
    number = models.CharField('course number', maxlength=6)
    title = models.CharField('course title', maxlength=100)
    semester = models.ForeignKey(Semester)
    year = models.PositiveIntegerField()

Steps to reproduce:

  1. In the admin, click Courses.
  2. Click add course.
  3. Click plus next to Semester dropdown.
  4. Fill in semester name.
  5. Click save.

What happens:

  • The add semester popup window goes blank.
  • The add semester popup window does not close itself and must be closed manually.
  • The new semester entry does get created in the database.
  • The semester dropdown in the add course form does not get populated with the newly created semester like it should.

Attachments (1)

pk-popup-close.diff (849 bytes ) - added by deryck@… 18 years ago.
String primary key values must be quoted or JavaScript assumes it's a variable.

Download all attachments as: .zip

Change History (5)

by deryck@…, 18 years ago

Attachment: pk-popup-close.diff added

String primary key values must be quoted or JavaScript assumes it's a variable.

comment:1 by deryck, 18 years ago

Summary: admin popup window stays open after adding and saving an item that has a primary_key=True field[patch] admin popup window stays open after adding and saving an item that has a primary_key=True field

Change summary to indicate patch.

comment:2 by Adrian Holovaty, 18 years ago

Resolution: fixed
Status: newclosed

(In [3553]) Fixed #2500 -- Fixed bug in admin related-object pop-up window when using a primary key value that isn't an integer. Thanks, Gary Wilson and deryck@…

comment:3 by Adrian Holovaty, 18 years ago

FYI, in the solution I came up with, I ended up just relying on the fact that the repr() of the primary-key value would be safely quoted -- so it works for integer and string values alike.

comment:4 by Adrian Holovaty, 18 years ago

(In [3613]) Fixed bug in [3553] -- Changed admin JavaScript quoting for related-object popup window not to use repr(), because that produces values such as 123L for longints. Refs #2500

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