Monday 15 March 2010

mysql - How can i make the tree like menus from python list -


I have the file name in the list with folders. The list contains 2000 file names such as

  country / US / New York / file 1.pdf country / australia / sydney / file 1.pdf country / canada / toronto / bla / blabla / file2.pdf   

and so on.

I want to index those files in the database so that I have the hierarchical directory structure.

In my Django app

country --- America, Australia, Canada

Then I click on a country , Then want to get it at the second level, the folders level and so on and at the end I want to see the file if there are no other folders.

Instead of checking my storage Yuri time, I want to store all this information in my database so that my web pages are displayed by DB and when the user clicks on the download, > Storage

How do I get that model or database table? / P>

I recommend the following types:

create Examples of how to store your tree structure and files:

  class modal: # Basic key for the original node class file (model): Node # node name # For example, file path to file on disk # path name    

then that will put your files in one or a few directories Moves in Hen) also you can change the name by using the hash of the file (for example).

Update Model file by inserting a new path to your files.

It is easy to show you the file and can create the path for the file etc. For model node [django-mptt] [1] (There are other solutions for the Django, Google do) to manage a tree like a skilled ADI.

You can also create your own DJENGO storage backend (or find many solutions on the Internet).

  • UPDATED

    You can add new files using the deegago admin. You should use the Amazon S3 Django storage backend.

    Change:

      class file (model): node # foreign key for node name # File file name # Django models.FileField    

    In this case you do not have to update the index.

  • No comments:

    Post a Comment