DJANGO timezone.now is diffefent to datetime.now after we set the timezone config in setting.py

2018-01-18 Thread Lau Louis
Hi I am confused about the timezone setting. I have my OS timezone set to 'Asia/Shanghai', and my MYSQL/Mariadb is also using 'Asia/Shanghai' timezone. So i tried to configure the timezone in DJANGO settings.py LANGUAGE_CODE = 'en-us' TIME_ZONE = 'Asia/Shanghai' USE_I18N = True USE_L10N =

Re: Comparing DateTimeField to datetime.now()

2010-07-14 Thread Chris McComas
This worked: import datetime Then, use 'datetime.datetime.now()' instead of 'datetime.now()' Thanks guys! On Jul 14, 11:57 am, Subhranath Chunder <subhran...@gmail.com> wrote: > How did u import the datetime module? > If you did: > > a> > import datetime > Then,

Re: Comparing DateTimeField to datetime.now()

2010-07-14 Thread Subhranath Chunder
How did u import the datetime module? If you did: a> import datetime Then, use 'datetime.datetime.now()' instead of 'datetime.now()' b> from datetime import datetime Then 'datetime.now()' should work correctly. Thanks, Subhranath Chunder. On Wed, Jul 14, 2010 at 9:13 PM, Chris M

Re: Comparing DateTimeField to datetime.now()

2010-07-14 Thread jaymzcd
This code works fine for me: In [1]: from gallery.models import Gallery In [2]: g = Gallery.objects.all()[0] In [3]: g.created_at Out[3]: datetime.datetime(2010, 4, 1, 7, 11, 51) In [4]: import datetime In [5]: n = datetime.datetime.now() In [6]: g.created_at > n Out[6]: False In [7]:

Re: Comparing DateTimeField to datetime.now()

2010-07-14 Thread Daniel Roseman
On Jul 14, 4:43 pm, Chris McComas wrote: > This is my model, I'm trying to set it so that if the game is in the > future, based on the field date, then to return True, if not return > False. > > http://dpaste.com/218111/ > > I am importing datetime in my models.py but for

Comparing DateTimeField to datetime.now()

2010-07-14 Thread Chris McComas
This is my model, I'm trying to set it so that if the game is in the future, based on the field date, then to return True, if not return False. http://dpaste.com/218111/ I am importing datetime in my models.py but for some reason it's giving me nothing. I tried displaying future and nothing

Re: how encrypt datetime.now with python?

2009-07-30 Thread Asinox
Thanks a lot guys :) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to

Re: how encrypt datetime.now with python?

2009-07-30 Thread Adam Peacock
That will work, as long as the parent doesn't need to go back into a native object easily - if s/he needs to easily get back into a datetime object, use pickle: import pickle import base64 toEncode = pickle.dumps(datetime.now()) encoded = base64.encodestring(toEncode) decoded = base64

Re: how encrypt datetime.now with python?

2009-07-30 Thread Luke Seelenbinder
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 convert it to a string: str(datetime.now()) Luke luke.seelenbin...@gmail.com "I [may] disapprove of what you say, but I will defend to the death your right to say it." -- Voltaire Asinox wrote: > hi guys, i want to encrypt the

how encrypt datetime.now with python?

2009-07-30 Thread Asinox
hi guys, i want to encrypt the "datetime.now()" , im try with base64 but base64 need string... how ill encrypt ? Thanks :) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. T

Re: Different time zone for server and editors screwing up show_from__lte = datetime.now()

2008-06-03 Thread Rodrigo Culagovski
re due, like so: > > from datetime import datetime > > current_banners = Banner.objects.filter(show_from__lte = > datetime.now()) > > However, the server is not in the same time zone as the people editing > the site, so the timing's off by the time delta between the two. >

Different time zone for server and editors screwing up show_from__lte = datetime.now()

2008-06-03 Thread Rodrigo Culagovski
I have a Banner model with a show_from DateTimeField, which I filter to make sure I'm only showing them after they're due, like so: from datetime import datetime current_banners = Banner.objects.filter(show_from__lte = datetime.now()) However, the server is not in the same time zone

Re: Error when I use datetime.now()

2007-10-20 Thread Dirk Eschler
models.TextField("Comments", maxlength=1000) > etc... > > def save(self): > self.comments += "This is a string - " + datetime.now() + " > This is a string " > > > > Whenever, I save my order class I get t

Re: Error when I use datetime.now()

2007-10-19 Thread Michael Newman
try datetime.now().__str__() or if you want to make it pretty try datetime.now().strftime(YourCustomFormatHere). Look at http://docs.python.org/lib/strftime-behavior.html#strftime-behavior Your problem is a datetime object is a not a string. Both those above examples turn it into a string

Error when I use datetime.now()

2007-10-19 Thread Greg
save(self): self.comments += "This is a string - " + datetime.now() + " This is a string " Whenever, I save my order class I get the following error: TypeError at /admin/plush/order/1/ cannot concatenate 'str' and 'datetime.date

datetime.now()

2006-12-07 Thread Todd O'Bryan
How can I get the current time in a way that respects the time zone I've set in Django settings? Or, alternatively, how do I convert a string like 'America/New York' into a timezone object? Thanks, Todd --~--~-~--~~~---~--~~ You received this message because

Re: When to use django.db.models.LazyDate() and when datetime.now()?

2006-06-10 Thread Rudolph
Thanks Luke, very nicely explained! Rudolph --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group,