#5752: DateTime fields with default=datetime.now don't fill properly in
model.AddManipulator
--------------------------------------------------+-------------------------
Reporter:  Wesley Fok <[EMAIL PROTECTED]>  |       Owner:  nobody       
  Status:  new                                    |   Component:  Uncategorized
 Version:  SVN                                    |    Keywords:               
   Stage:  Unreviewed                             |   Has_patch:  0            
--------------------------------------------------+-------------------------
 This is all happening under Django SVN 5819.

 Say I have an Entry model like so:
 {{{
 class Entry(models.Model):
     title = models.CharField(maxlength=255)
     content = models.TextField()
     is_published = models.BooleanField(default=True)
     date_published = models.DateTimeField(default=datetime.now(),
 blank=None, null=None)
 }}}

 which is hooked into the create_object generic view (not directly, but via
 a custom view that eventually returns create_object). What I would expect
 in the ensuing form is two fields for date and time, where the date and
 time reflect the current date and time. Shift-reloading that page should
 refresh the time so that it's always current. Instead, what happens is the
 time bounces back and forth between two times, neither of which are the
 current time; they are both times in the near past.

 This is not a browser refresh problem; some digging revealed that the
 problem occurs even when you attempt to query the model's AddManipulator
 object:
 {{{
 >>> from datetime import datetime
 >>> from journal.blog.models import Entry
 >>> datetime.now()
 datetime.datetime(2007, 10, 14, 5, 20, 28, 863454)
 >>> Entry.AddManipulator().flatten_data()['date_published_time']
 '05:19:52'
 >>> datetime.now()
 datetime.datetime(2007, 10, 14, 5, 22, 1, 45406)
 >>> Entry.AddManipulator().flatten_data()['date_published_time']
 '05:19:52'
 }}}

 Three minutes has passed since the Entry import, but the time in the
 Manipulator hasn't changed. It also doesn't change if I re-import Entry as
 Entry2 and try again. In fact, the only thing that changes the time is
 creating a new Python shell and importing Entry. In fact, the time seems
 to reflect the initial import of the Entry model into the Python
 environment. This doesn't seem like desirable behaviour.

 My guess is that on the web form, the date shows one of two times because
 I'm currently running an Apache/mod_python setup with the ServerLimit set
 to 2; every time the date_published time changes, I'm on a different
 server instance. The times refresh occasionally, which I expect is due to
 an Apache child instance being recycled after hitting MaxRequestsPerChild.

 Unfortunately I have no idea where to start to fix this, and because this
 all falls under the oldforms framework I don't know if it'll ever be
 fixed, but I leave that to the Django gods.

-- 
Ticket URL: <http://code.djangoproject.com/ticket/5752>
Django Code <http://code.djangoproject.com/>
The web framework for perfectionists with deadlines
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to