Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
'NoneType' object has no attribute 'datetime' bug?
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  7 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
dobrysmak  
View profile  
 More options Jul 14 2012, 8:01 am
From: dobrysmak <lukasz.szyman...@gmail.com>
Date: Sat, 14 Jul 2012 05:01:05 -0700 (PDT)
Local: Sat, Jul 14 2012 8:01 am
Subject: 'NoneType' object has no attribute 'datetime' bug?

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 must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ernesto Guevara  
View profile  
 More options Jul 14 2012, 1:15 pm
From: Ernesto Guevara <eguevara2...@gmail.com>
Date: Sat, 14 Jul 2012 14:15:56 -0300
Local: Sat, Jul 14 2012 1:15 pm
Subject: Re: 'NoneType' object has no attribute 'datetime' bug?

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>


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
dobrysmak  
View profile  
 More options Jul 16 2012, 4:21 am
From: dobrysmak <lukasz.szyman...@gmail.com>
Date: Mon, 16 Jul 2012 01:21:00 -0700 (PDT)
Subject: Re: 'NoneType' object has no attribute 'datetime' bug?

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ł:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
tWoolie  
View profile  
 More options Jul 16 2012, 5:15 am
From: tWoolie <rocker.of.b...@gmail.com>
Date: Mon, 16 Jul 2012 02:15:52 -0700 (PDT)
Local: Mon, Jul 16 2012 5:15 am
Subject: Re: 'NoneType' object has no attribute 'datetime' bug?

somehow, your global datetime variable is being clobbered with the value
None. Find where that happens, and your bug will disappear.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Melvyn Sopacua  
View profile  
 More options Jul 30 2012, 8:16 am
From: Melvyn Sopacua <m.r.sopa...@gmail.com>
Date: Mon, 30 Jul 2012 14:16:39 +0200
Local: Mon, Jul 30 2012 8:16 am
Subject: Re: 'NoneType' object has no attribute 'datetime' bug?
On 14-7-2012 14:01, dobrysmak wrote:

> def close_coupon(self):
> current_date = datetime.datetime.now() today =
> datetime.datetime.combine(datetime.date.today(), datetime.time(19,30))
> .
>   .
> end_date = current_date

This function is stripped down I suppose, because it does nothing useful:
- it changes a few local variables (not values of the model)
- today is unused
- end_date is set to current_date which seems odd.

My guess is that you want the end_date set to half past seven of the
current_date:

def close_coupon(self) :
        from django.utils import timezone
        current_date = timezone.now()
        end_date = current_date.replace(hour=19, minutes=30)
        self.current_date = current_date
        self.end_date = end_date

--
Melvyn Sopacua


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Masklinn  
View profile  
 More options Jul 30 2012, 8:27 am
From: Masklinn <maskl...@masklinn.net>
Date: Mon, 30 Jul 2012 14:27:54 +0200
Local: Mon, Jul 30 2012 8:27 am
Subject: Re: 'NoneType' object has no attribute 'datetime' bug?

On 2012-07-16, at 10:21 , dobrysmak wrote:

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

Sounds like you have a parameter called "datetime" or you create a
variable called "datetime" somewhere, which clobbers the module.

Check the rest of the file, you surely have a line along the lines of
`datetime = None` somewhere.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Peter of the Norse  
View profile  
 More options Aug 15 2012, 12:42 am
From: Peter of the Norse <RahmC...@Radio1190.org>
Date: Tue, 14 Aug 2012 22:42:10 -0600
Local: Wed, Aug 15 2012 12:42 am
Subject: 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:

Peter of the Norse
RahmC...@Radio1190.org

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »