For timestamp in int you should use time() from time package (not datetime.time). It return float number, but can be easy convert to int.
> Hello, > > I'm new to Django, and I have a question. > I have a ImageField() in my model, and I obviously want that each image has > a unique name in my filesystem. How to do this? > > My idea was to include the timestamp in the name of the image (I'll never > have more than one image uploaded per second). So I coded something like > this for the name of the uploaded image: > f, ext = os.path.splitext(filename) > return "images/%d%s" % (datetime.now(), ext) > > But I get an error: "%d format: a number is required, not datetime.datetime" > > So my question is: how to get the timestamp of the current time as an > integer? > Thanks for your help!
signature.asc
Description: This is a digitally signed message part.