Thank's for help , i did this and now i've got this AttributeError at /wejdz-do-gry/76/ 'NoneType' object has no attribute 'now'
This is strange because the shell import works fine but the server script throus an exception. >>> from datetime import datetime, time, date > >>> print datetime.now() > 2012-07-14 14:14:17.897023 > >>> print datetime.combine(date.today(),time(19,30)) > 2012-07-14 19:30:00 > >>> > Ok, that's true but the script does not even reach the 'combine' function it died on 'now'. W dniu sobota, 14 lipca 2012 19:15:56 UTC+2 użytkownik Guevara napisał: > > Try this: > > from datetime import datetime, time, date > > current_date = datetime.now() > > today = datetime.combine(date.today(), time(19,30)) > > Look: > > >>> from datetime import datetime, time, date > >>> print datetime.now() > 2012-07-14 14:14:17.897023 > >>> print datetime.combine(date.today(),time(19,30)) > 2012-07-14 19:30:00 > >>> > > o/ > > > 2012/7/14 dobrysmak <lukasz.szyman...@gmail.com> > >> Hi guys, >> i have run into this. >> >> Traceback: >> File >> "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in >> get_response >> 111. response = callback(request, *callback_args, **callback_kwargs) >> File >> "/usr/local/lib/python2.7/dist-packages/django/contrib/auth/decorators.py" >> in _wrapped_view >> 20. return view_func(request, *args, **kwargs) >> File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py" >> in _wrapped_view >> 91. response = view_func(request, *args, **kwargs) >> File "/home/user/dev/xyz/coupon/views.py" in enter_game >> 69. Coupon(coupon=coupon, player=player, credicts=credicts).save() >> File "/home/user/dev/xyz/coupon/models.py" in save >> 253. self.coupon.close_coupon() >> File "/home/user/dev/xyz/coupon/models.py" in close_coupon >> 78. current_date = datetime.datetime.now() >> >> Exception Type: AttributeError at /wejdz-do-gry/49/ >> Exception Value: 'NoneType' object has no attribute 'datetime' >> Request information: >> GET: No GET data >> >> and the cuntion "close_coupon" looks like this >> >> class Coupon(models.Model): . >> . >> . end_date = models.DateTimeField(default=None, null=True, blank=True) >> def close_coupon(self): >> current_date = datetime.datetime.now() today = >> datetime.datetime.combine(datetime.date.today(), datetime.time(19,30)) >> . >> . >> end_date = current_date >> >> Don't know if that's a bug. Does anyone know how to deal with this issue? >> Cheers! >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Django users" group. >> To view this discussion on the web visit >> https://groups.google.com/d/msg/django-users/-/iH-0-noK-zkJ. >> To post to this group, send email to django-users@googlegroups.com. >> To unsubscribe from this group, send email to >> django-users+unsubscr...@googlegroups.com. >> For more options, visit this group at >> http://groups.google.com/group/django-users?hl=en. >> > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/cqKjBDZ5XgEJ. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.