GithubHelp home page GithubHelp logo

shaunbrady / django-filemanager Goto Github PK

View Code? Open in Web Editor NEW

This project forked from imgiitroorkee/django-filemanager

0.0 1.0 0.0 871 KB

A simple Django app to browse files on server

License: MIT License

django-filemanager's Introduction

Filemanager

Filemanager is a simple Django app to browse files on server. You can also integrate this filemanager with CKEditor.

Screenshot

screenshot

Quick start

Add "filemanager" to your INSTALLED_APPS setting like this::

INSTALLED_APPS = (
    ...
    'filemanager',
)

Usage

  • As a filemanager : To upload files on server by a user to a directory and let him manage his directory by adding, renaming and deleting files and folders inside it.

  • Integrating it with CKEditor for the functionality of "Browse Server".

As a filemanager

In urls.py of your app to make filemanager run at url /abc/

from filemanager import path_end
urlpatterns = patterns('app',
   .
   .
   (r'^abc/'+path_end,'view'),
)

And then write the view in views.py of your app

from filemanager import FileManager
from settings import MEDIA_ROOT
def view(request,path):
  fm = FileManager(MEDIA_ROOT+'user_folder/')
  return fm.render(request,path)

And it is done.

Adding constraints to Filemanager : FileManager _init_ is defined as

def __init__(self,basepath,ckeditor_baseurl='',maxfolders=50,maxspace=5*1024,maxfilesize=1*1024,public_url_base=None,extensions=None):
   """
   basepath: User's directory basepath in server.
   maxfolders: Maximum number of total nested folders allowed inside the user directory.
   maxspace (in KB): Maximum space allowed for the user directory.
   maxfilesize (in KB): Limit for the size of an uploaded file allowed in user directory.
   extensions: List of extensions allowed. Ex. ['pdf','html'] etc.
   public_base_url: A base_url if given there will be an option to copy file url with the given url_base.
   """

Hence one should also pass arguments like maxfolders, maxspace, maxfilesize if one doesn't want to use the default ones. If extensions list is not passed then all file-extensions are allowed for upload.

Integrating with CKEditor

Use filemanager.models.CKEditorField field in you model. Or you can use filemanager.widgets.CKEditorWidget as a widget for CKEditor in forms. Both classes can take an extra argument filemanager_url while making instances from them. Suppose you want to run filemanager at url /abc/ in your app then make changes in urls.py and views.py like above. Then in CKEditorField or CKEditorWidget pass the url of filemanager as argument filemanager_url. For example in models.py :

from filemanager.models import CKEditorField
class MyModel(models.Model):
  .
  .
  content = CKEditorField(filemanager_url='/app/abc/')

django-filemanager's People

Contributors

shaunbrady avatar shhaumb avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.