Code

Opened 8 years ago

Closed 8 years ago

Last modified 8 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
Component: contrib.admin Version: master
Severity: normal Keywords:
Cc: gary.wilson@… Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

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@… 8 years ago.
String primary key values must be quoted or JavaScript assumes it's a variable.

Download all attachments as: .zip

Change History (5)

Changed 8 years ago by deryck@…

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

comment:1 Changed 8 years ago by deryck

  • Summary changed from admin popup window stays open after adding and saving an item that has a primary_key=True field to [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 Changed 8 years ago by adrian

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

(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 Changed 8 years ago by adrian

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 Changed 8 years ago by adrian

(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

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.