On Samstag, 20. Oktober 2007, Greg wrote:
> Hello,
> I have a class called Orders that tries to add the current date to
>
> it's comments field when it's saved. Here is my code:
> >from datetime import datetime
>
> class Order(models.Model):
> comments = models.TextField("Comments",
try datetime.now().__str__() or if you want to make it pretty try
datetime.now().strftime(YourCustomFormatHere). Look at
http://docs.python.org/lib/strftime-behavior.html#strftime-behavior
Your problem is a datetime object is a not a string. Both those above
examples turn it into a string.
On
Hello,
I have a class called Orders that tries to add the current date to
it's comments field when it's saved. Here is my code:
from datetime import datetime
class Order(models.Model):
comments = models.TextField("Comments", maxlength=1000)
etc...
def save(self):
3 matches
Mail list logo