[Answer]-How to store this list as individual data's in Django database?

1👍

You’re passing just the filename (i.e.'__init__.py'), not the full path (i.e. '/module/__init__.py') to os.stat()

I suggest doing something like so:

>>> folder = '/Python27/Doc'
>>> files = os.listdir(folder)
>>> for filename in files:
    fullname = os.path.join(folder, filename)
    print fullname, os.path.getsize(fullname)


/Python27/Doc\python27.chm 5754439
👤Alex L

0👍

you need to prepend the base directory location (os.dirname(__file__) … (probably)) ,to the filename before you stat it …

Leave a comment