views:

25

answers:

1

Hi, There is something i don't get in django template system. I have a FileField in my model called myfile. If i pass an instance of my model to a template, i can access file.size (this is an example). Form where this variable 'size' come from?? it's not part of the FileField class as far as i know. A small test:

def save(self):
      super(UploadItem, self).save()
      import logging; logging.debug(file.size)

this snippet generates this error: type object 'file' has no att

is django so magic?

+2  A: 

If you want to retrieve the upload file's on-disk filename, or a URL that refers to that file, or the file's size, you can use the name, url and size attributes; see Managing files.

http://docs.djangoproject.com/en/1.2/ref/models/fields/#filefield

http://docs.djangoproject.com/en/1.2/topics/files/

S.Lott
@S.Lott is there a way to access filename from Model side?(i need this to create a slug)
maroxe