#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 , 16 years ago
comment:2 by , 16 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
comment:4 by , 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.
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.