|
It seems the date/clock hangs and doesn't advance unless I restart the apache server. For example, default dates that are supposed to be 'today' show up as yesterday's date until I reset the server. Also, db queries get the wrong data when I use 'today' as criteria, until I reset the server, then all's well. Any help is much appreciated. Info: Django/Python2.7 app on shared hosting here on Webfaction |
|
It sounds to me like you've got a field defined in your model that uses Instead of using that function, you should use the Another option might be to set the default value to the function itself, eg Regarding your "today" queries, it sounds like a similar issue, but it's hard to be sure without seeing your code. You're exactly right. Here's my code from models.py: class Run(models.Model): date = models.DateField(default=date.today) distance = models.DecimalField(decimal_places=2, max_digits=5) However, if I do auto_now, my user can't set another date in the form, correct? I'm going to have to find a way for the form to do this. I took the default out of the Model and put it into the form when called from views.py:
Seems to work. We'll see tomorrow. I think that is going to give you the same problem. As Sean mentioned, you need to call date.today instead of date.today() Remove the () from the end otherwise it will only be called once at run time. Removing the () didn't work since I had this in my model, which is only run once (when the server starts). I moved the code into my views.py and sent it to the form. Beginner's mistake. Thanks for the help! |
Can you provide an example field from your model that you are seeing this issue on? Please provide more details if you can.