import pytz
user_timezone = session.plugin_timezone_tx or 'UTC'
db.define_table('events',
Field('event_time', 'datetime', default = request.now, update = request.now,
requires=IS_DATETIME(format=('%m-%d-%Y %H:%M'), timezone=pytz.timezone(user_timezone))),
But to get it to work on pythonanywhere.com I have to setup my db.py as follows. Any ideas why?
import pytz
db.define_table('events',
Field('event_time', 'datetime', default = request.now, update = request.now,
requires=IS_DATETIME(format=('%m-%d-%Y %H:%M'), timezone=pytz.timezone("US/Central"))),
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to a topic in the Google Groups "web2py-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/wL2y7s-FJWU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
{{if timezone_is_unknown: }}
<script>
$(function() {
var tz_name = jstz.determine();
$.get("{{=URL('default', 'define_timezone')}}", tz_name);
});
</script>
def define_timezone():
"""Call ajax to determine user timezone"""
tz_name = request.vars.name
from pytz import all_timezones_set
if tz_name in all_timezones_set:
session.user_timezone = tz_name
from pytz import timezone
timezone_user = session.user_timezone or timezone('UTC')
timezone_is_unknown = session.user_timezone is NoneIS_DATETIME(format=("%m-%d-%Y %H:%H), timezone = pytz.timezone(timezone_user) )At app, the Hour "your PC" is datetime.now() simulating datetime of user, just that it's datetime of the pythonanywhere.
I think that I know where are missing pytz.. you put library in controller define_timezone() ..
To unsubscribe from this group and all its topics, send an email to web2py+unsubscribe@googlegroups.com.
Might put on github , but dont I can access them nowI will analyse your code by here , by while.Later I will access github.In error page, which file show the error?
Em segunda-feira, 11 de julho de 2016 09:31:04 UTC-3, Jeff Riley escreveu: