Django

Code

Ticket #2500 (closed: fixed)

Opened 2 years ago

Last modified 2 years ago

[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@gmail.com> Assigned to: adrian
Milestone: Component: django.contrib.admin
Version: SVN Keywords:
Cc: gary.wilson@gmail.com Triage Stage: Unreviewed
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

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

pk-popup-close.diff (0.8 kB) - added by deryck@samba.org on 08/11/06 00:10:49.
String primary key values must be quoted or JavaScript? assumes it's a variable.

Change History

08/11/06 00:10:49 changed by deryck@samba.org

  • attachment pk-popup-close.diff added.

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

08/11/06 00:12:18 changed 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.

08/11/06 00:31:08 changed by adrian

  • status changed from new to closed.
  • resolution set to fixed.

(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@samba.org

08/11/06 00:31:55 changed 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.

08/18/06 16:39:29 changed 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/Change #2500 ([patch] admin popup window stays open after adding and saving an item that has a primary_key=True field)




Change Properties
Action