Code

Opened 4 years ago

Closed 4 years ago

Last modified 3 years ago

#12705 closed (fixed)

Admin date widget not working on inlines until after validation failure

Reported by: russellm Owned by: jezdez
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 russellm)

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

Download all attachments as: .zip

Change History (11)

comment:1 Changed 4 years ago by russellm

  • Description modified (diff)
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted
  • Version changed from 1.1 to SVN

comment:2 Changed 4 years ago by jezdez

  • Owner changed from nobody to jezdez
  • Status changed from new to assigned

comment:3 Changed 4 years ago by jezdez

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 4 years ago by jezdez

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

comment:4 follow-up: Changed 4 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 4 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 4 years ago by jbronn

Now works with SelectFIlter

comment:6 follow-up: Changed 4 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 4 years ago by jbronn

  • Patch needs improvement unset
  • Triage Stage changed from Accepted to 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 Changed 4 years ago by jbronn

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

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

comment:9 Changed 3 years ago by jacob

  • milestone 1.2 deleted

Milestone 1.2 deleted

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.