Opened 16 years ago

Closed 16 years ago

Last modified 11 years ago

#7717 closed Uncategorized (invalid)

python now() and javascript now-button in admin not the same

Reported by: mikaelm Owned by: nobody
Component: contrib.admin Version: newforms-admin
Severity: Normal Keywords: now_button
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

If you have a datetimefield, and press the now button in the admin view you will enter the local time according to your computers timezone, and not according to the servers settings. This might confuse the user.

E.g:
You have a blog that do not publish the blog post immediately, but after a specific date and time. By pressing the "now" button in the django admin the user would expect the blog post to appear immediately in the blog, but might not do that if the timezone of the server and the computer differ.

#model.py
class BlogPosts(models.Model):

title = models.CharField(_("title"),max_length=200)

body = models.TextField(_("body"))

visible_after = models.DateTimeField(_("post visible after"))


#views.py
def list(request):

queryset=Post.objects.filter(visble_afterlte=datetime.now).order_by("-visible_after")


return list_detail.object_list(

request,
queryset=queryset,
paginate_by=paginate_by,
page=page_no,
template_name=template_name,

)

This is perhaps not a bug, but might be perceived as such by the users. One solution would use some ajax-magic that queries the server for the server's own localtime.

Change History (6)

comment:1 by James Bennett, 16 years ago

This is expected behavior for JavaScript; if your users are surprised to see that the value they enter in the box for the date/time is the value that actually gets used, perhaps you should have a training session with them to explain this.

comment:2 by James Bennett, 16 years ago

Resolution: invalid
Status: newclosed

comment:3 by (none), 15 years ago

milestone: post-1.0

Milestone post-1.0 deleted

comment:4 by Aymeric Augustin, 13 years ago

Easy pickings: unset
Severity: Normal
Type: Uncategorized
UI/UX: unset

The same idea was accepted in #14253, and that ticket describes a solution.

comment:5 by Aymeric Augustin, 11 years ago

There's a new attempt to fix this in #20663.

comment:6 by Aymeric Augustin <aymeric.augustin@…>, 11 years ago

In 7e6d852bac4de2d5ed2d5ddeabf71482d644ef51:

Fixed #20663 -- "Today" and "now" admin shortcuts.

Changed the shortcuts next to date and time intput widgets
to account for the current timezone.

Refs #7717, #14253 and #18768.

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