Opened 15 years ago

Closed 15 years ago

Last modified 13 years ago

#12705 closed (fixed)

Admin date widget not working on inlines until after validation failure

Reported by: Russell Keith-Magee Owned by: Jannis Leidel
Component: contrib.admin Version: dev
Severity: Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Russell Keith-Magee)

Sample models.py:

class Publisher(models.Model):
   name = models.CharField(max_length=300)

class Book(models.Model):
   name = models.CharField(max_length=300)
   publisher = models.ForeignKey(Publisher)
   pubdate = models.DateField()

admin.py:

class BookInline(admin.TabularInline):
    model = Book

class PublisherAdmin(admin.ModelAdmin):
    inlines = [BookInline]

admin.site.register(Publisher, PublisherAdmin)

Test procedure:

  1. Create a new publisher
  2. Click the "Add a new book" button
  3. Set the name of the book.
  4. Press the today button. Nothing happens - the date doesn't populate the date field.
  5. Press the calendar widget. Select a date. The date doesn't populate the date field.
  6. Save the object. This should cause a validation error, as pubdate is a required field
  7. Press the today button. It works!
  8. Press the calendar widget. It works!

I've observed this using Safari 4.0.4, Firefox 3.5.7, and Chrome 4.0.249.49 (35163) beta on OSX 10.5.8.

Attachments (2)

12705.1.diff (5.7 KB ) - added by Jannis Leidel 15 years ago.
Added a workaround for the DateTimeShortcuts widgets, still a solution for the FilterSelect missing
12705.2.diff (9.0 KB ) - added by jbronn 15 years ago.
Now works with SelectFIlter

Download all attachments as: .zip

Change History (11)

comment:1 by Russell Keith-Magee, 15 years ago

Description: modified (diff)
Triage Stage: UnreviewedAccepted
Version: 1.1SVN

comment:2 by Jannis Leidel, 15 years ago

Owner: changed from nobody to Jannis Leidel
Status: newassigned

comment:3 by Jannis Leidel, 15 years ago

From what I understand this happens because the event handlers of the admin date widget aren't correctly handled when adding inlines dynamically.

I think we could work around that by re-initializing the calendar widgets when adding a new inline as long as we don't have a better way to tell the widget not lose the event handler.

by Jannis Leidel, 15 years ago

Attachment: 12705.1.diff added

Added a workaround for the DateTimeShortcuts widgets, still a solution for the FilterSelect missing

comment:4 by jbronn, 15 years ago

Patch doesn't fix my manifestation of the problem, as they don't work on newly added inlines either (as I described in dupe #12835).

in reply to:  4 comment:5 by jbronn, 15 years ago

Replying to jbronn:

Patch doesn't fix my manifestation of the problem

User error on my part, the patch does indeed work.

by jbronn, 15 years ago

Attachment: 12705.2.diff added

Now works with SelectFIlter

comment:6 by jbronn, 15 years ago

Has patch: set
Patch needs improvement: set

Appears to work fine in Firefox/Safari/Chrome; however still having problems with IE7.

in reply to:  6 comment:7 by jbronn, 15 years ago

Patch needs improvement: unset
Triage Stage: AcceptedReady for checkin

Replying to jbronn:

still having problems with IE7.

User error, again. Works in IE7; after running test suite will check in.

comment:8 by jbronn, 15 years ago

Resolution: fixed
Status: assignedclosed

(In [12454]) Fixed #12705 -- Date/time and select filter widgets now work again with newly added inline forms in the admin.

comment:9 by Jacob, 13 years ago

milestone: 1.2

Milestone 1.2 deleted

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