#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 )
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:
- Create a new publisher
- Click the "Add a new book" button
- Set the name of the book.
- Press the today button. Nothing happens - the date doesn't populate the date field.
- Press the calendar widget. Select a date. The date doesn't populate the date field.
- Save the object. This should cause a validation error, as pubdate is a required field
- Press the today button. It works!
- 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)
Change History (11)
comment:1 by , 15 years ago
Description: | modified (diff) |
---|---|
Triage Stage: | Unreviewed → Accepted |
Version: | 1.1 → SVN |
comment:2 by , 15 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:3 by , 15 years ago
by , 15 years ago
Attachment: | 12705.1.diff added |
---|
Added a workaround for the DateTimeShortcuts widgets, still a solution for the FilterSelect missing
follow-up: 5 comment:4 by , 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).
comment:5 by , 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.
follow-up: 7 comment:6 by , 15 years ago
Has patch: | set |
---|---|
Patch needs improvement: | set |
Appears to work fine in Firefox/Safari/Chrome; however still having problems with IE7.
comment:7 by , 15 years ago
Patch needs improvement: | unset |
---|---|
Triage Stage: | Accepted → Ready 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 , 15 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
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.