Opened 7 years ago

Closed 7 years ago

Last modified 5 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: master
Severity: Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

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 7 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 7 years ago.
Now works with SelectFIlter

Download all attachments as: .zip

Change History (11)

comment:1 Changed 7 years ago by Russell Keith-Magee

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

comment:2 Changed 7 years ago by Jannis Leidel

Owner: changed from nobody to Jannis Leidel
Status: newassigned

comment:3 Changed 7 years ago by Jannis Leidel

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.

Changed 7 years ago by Jannis Leidel

Attachment: 12705.1.diff added

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

comment:4 Changed 7 years ago by jbronn

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).

comment:5 in reply to:  4 Changed 7 years ago by jbronn

Replying to jbronn:

Patch doesn't fix my manifestation of the problem

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

Changed 7 years ago by jbronn

Attachment: 12705.2.diff added

Now works with SelectFIlter

comment:6 Changed 7 years ago by jbronn

Has patch: set
Patch needs improvement: set

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

comment:7 in reply to:  6 Changed 7 years ago by jbronn

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

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 Changed 5 years ago by Jacob

milestone: 1.2

Milestone 1.2 deleted

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