Hi,

Here's my model :

class Image(meta.Model):
    paragraph = meta.ForeignKey(Paragraph)
    creation_date = meta.DateTimeField(null=False, auto_now_add=True)
    update_date = meta.DateTimeField(null=False, auto_now=True)
    name = meta.CharField(maxlength = 255, blank = True)
    img = meta.ImageField(upload_to='imgs')

Here's the traceback

File
"/home/saruman/dev/python/django/lang/python241/lib/python2.4/site-packages/django/core/handlers/base.py",
line 64, in get_response
    response = callback(request, **param_dict)

  File
"/home/saruman/dev/python/django/lang/python241/lib/python2.4/site-packages/django/views/admin/main.py",
line 778, in add_stage
    pk_value = getattr(new_object, opts.pk.column)

  File
"/home/saruman/dev/python/django/lang/python241/lib/python2.4/site-packages/django/utils/functional.py",
line 3, in _curried
    return args[0](*(args[1:]+moreargs), **dict(kwargs.items() +
morekwargs.items()))

  File
"/home/saruman/dev/python/django/lang/python241/lib/python2.4/site-packages/django/core/meta/__init__.py",
line 1471, in manipulator_save
    f.save_file(new_data, new_object, change and self.original_object
or None, change, rel=False)

  File
"/home/saruman/dev/python/django/lang/python241/lib/python2.4/site-packages/django/core/meta/fields.py",
line 445, in save_file
    FileField.save_file(self, new_data, new_object, original_object,
change, rel)

  File
"/home/saruman/dev/python/django/lang/python241/lib/python2.4/site-packages/django/core/meta/fields.py",
line 417, in save_file
    getattr(new_object, 'save_%s_file' %
self.name)(new_data[upload_field_name]["filename"],
new_data[upload_field_name]["content"])

  File
"/home/saruman/dev/python/django/lang/python241/lib/python2.4/site-packages/django/utils/functional.py",
line 3, in _curried
    return args[0](*(args[1:]+moreargs), **dict(kwargs.items() +
morekwargs.items()))

  File
"/home/saruman/dev/python/django/lang/python241/lib/python2.4/site-packages/django/core/meta/__init__.py",
line 1042, in method_save_file
    self.save()

  File
"/home/saruman/dev/python/django/lang/python241/lib/python2.4/site-packages/django/utils/functional.py",
line 3, in _curried
    return args[0](*(args[1:]+moreargs), **dict(kwargs.items() +
morekwargs.items()))

  File
"/home/saruman/dev/python/django/lang/python241/lib/python2.4/site-packages/django/core/meta/__init__.py",
line 787, in method_save
    db_values + [pk_val])

  File
"/home/saruman/dev/python/django/lang/python241/lib/python2.4/site-packages/django/core/db/base.py",
line 10, in execute
    result = self.cursor.execute(sql, params)

ProgrammingError: ERREUR:  Syntaxe en entrée invalide pour le type
timestamp with time zone: «»

UPDATE maccaferri_images SET
paragraph_id='1',creation_date='',update_date='2005-09-24
07:29:45.401427',legende='yoyo',img='imgs/photo1.jpg',position='0'
WHERE id=1


I guess that the problem occurs when using a conjunction of a :

meta.DateTimeField(null=False, auto_now_add=True)
meta.ImageField(upload_to='imgs') or FileField I suppose.


It looks like during an insert :

1 - The entry is created in the DB
2 - The file is checked and saved on the filesystem
3 - The DB entry is update with the file informations

But the creation_date shouldn't be in the update query or shouldn't be
empty.

Am I right ??

Laurent.

Reply via email to