Tuesday, August 14, 2012

Re: 'NoneType' object has no attribute 'datetime' bug?

I had a similar problem in one of my views. It looked like:

from X import y

def my_func():
foo = y.baz()
...
y = foo + bar;

Since I was assigning to y later in the function, "y" represented a local variable throughout the function. Somewhere you have "datetime =", but it might be later in the method.

On Jul 14, 2012, at 6:01 AM, dobrysmak wrote:

> 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!

Peter of the Norse
RahmCoff@Radio1190.org



--
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 django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate