Opened 7 years ago

Closed 7 years ago

Last modified 20 months 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 Changed 7 years ago by ubernostrum

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

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

  • Resolution set to invalid
  • Status changed from new to closed

comment:3 Changed 6 years ago by anonymous

  • milestone post-1.0 deleted

Milestone post-1.0 deleted

comment:4 Changed 3 years ago by aaugustin

  • Easy pickings unset
  • Severity set to Normal
  • Type set to Uncategorized
  • UI/UX unset

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

comment:5 Changed 20 months ago by aaugustin

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

comment:6 Changed 20 months ago by Aymeric Augustin <aymeric.augustin@…>

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