GithubHelp home page GithubHelp logo

smacker / django-filebrowser-no-grappelli Goto Github PK

View Code? Open in Web Editor NEW

This project forked from sehmaschine/django-filebrowser

140.0 14.0 94.0 3.58 MB

Media-Management no Grappelli

License: Other

Python 60.49% JavaScript 17.52% CSS 3.83% HTML 17.25% Shell 0.91%
django filebrowser

django-filebrowser-no-grappelli's Introduction

Django FileBrowser

image

image

image

image

Media-Management. (based on https://github.com/sehmaschine/django-filebrowser)

The FileBrowser is an extension to the Django administration interface in order to:

  • browse directories on your server and upload/delete/edit/rename files.
  • include images/documents to your models/database using the FileBrowseField.
  • select images/documents with TinyMCE.

Requirements

FileBrowser 4.0 requires

No Grappelli

This fork removes the dependency on Grappelli.

Installation

Latest version:

pip install -e git+git://github.com/smacker/django-filebrowser-no-grappelli.git#egg=django-filebrowser

Stable version:

pip install django-filebrowser-no-grappelli

Documentation

http://readthedocs.org/docs/django-filebrowser/

It also has fake model to show filebrowser in admin dashboard, but you can disable it by setting FILEBROWSER_SHOW_IN_DASHBOARD = False.

Translation

https://www.transifex.com/projects/p/django-filebrowser/

Releases

  • FileBrowser 4.0.2 (July 18th, 2023): Compatible with Django 3/4
  • FileBrowser 3.8.0 (November 4th, 2019): Compatible with Django 1.11/2.0/2.1/2.2/3.0
  • FileBrowser 3.7.9 (November 3rd, 2019): Compatible with Django 1.8/1.9/1.10/1.11/2.0/2.1/2.2
  • FileBrowser 3.6.2 (March 7th, 2016): Compatible with Django 1.4/1.5/1.6/1.7/1.8/1.9

Older versions are available at GitHub, but are not supported anymore.

django-filebrowser-no-grappelli's People

Contributors

adamrt avatar ankhbayar avatar bastiaanraa avatar bessl avatar fetzig avatar fgmacedo avatar honi avatar igorsobreira avatar kanu avatar kevin1024 avatar kidwind avatar laat avatar lpomfrey avatar maciejwisniowski avatar merwok avatar michalwerner avatar mitshel avatar parsch avatar pulse-mind avatar rmaceissoft avatar sebassbm avatar sehmaschine avatar smacker avatar thomwiggers avatar timgraham avatar tomassommar avatar vdboor avatar vstoykov avatar waustin avatar willharris avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

django-filebrowser-no-grappelli's Issues

upload file not showing?

Hello,

I'm pretty new in django and python

I tried using the origin filebrowser (with grappelli)
everything is fine but I personally don't like the style in grappelli

then I found this! I tried immediately and glad it's working except the upload button is not showing

I tried using other browsers, created new project, turning off adblock nothing seems working for me

image

'WSGIRequest' object has no attribute 'REQUEST'

'WSGIRequest' object has no attribute 'REQUEST'
/local/lib/python2.7/site-packages/filebrowser/sites.py in browse, line 355
Environment:

Request Method: GET

Django Version: 1.9
Python Version: 2.7.6
Installed Applications:
('mptt',
 'django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django.contrib.sites',
 'datetimewidget',
 'virtenviro',
 'virtenviro.content',
 'virtenviro.news',
 'virtenviro.shop',
 'virtenviro.registration',
 'filebrowser')
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware',
 'django.middleware.locale.LocaleMiddleware')



Traceback:

File "/local/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
  149.                     response = self.process_exception_by_middleware(e, request)

File "/local/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
  147.                     response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "/local/lib/python2.7/site-packages/filebrowser/decorators.py" in decorator
  45.         return function(request, *args, **kwargs)

File "/local/lib/python2.7/site-packages/django/contrib/auth/decorators.py" in _wrapped_view
  23.                 return view_func(request, *args, **kwargs)

File "/local/lib/python2.7/site-packages/django/views/decorators/cache.py" in _wrapped_view_func
  57.         response = view_func(request, *args, **kwargs)

File "/local/lib/python2.7/site-packages/django/views/decorators/clickjacking.py" in wrapped_view
  39.         resp = view_func(*args, **kwargs)

File "/local/lib/python2.7/site-packages/filebrowser/sites.py" in browse
  355.             'is_popup': "pop" in request.REQUEST,   # ChangeList uses "pop"

Exception Type: AttributeError at /filebrowser/browse/
Exception Value: 'WSGIRequest' object has no attribute 'REQUEST'

base.py - sort_by_attr : '<' not supported between instances of 'float' and 'NoneType'

  • Python 3
  • Django 1.11.20
  • django-filebrowser-no-grappelli==3.7.8
  • botocore==1.12.183
  • boto3==1.9.183
  • django-storages==1.7.1

I am using django-storages/boto3 with a DigitalOcean space. While attempting to access /admin/filebrowser/browse/ I get the following error at base.py sort_by_attr function:
'<' not supported between instances of 'float' and 'NoneType'

Not sure if this is unique to Digital Ocean spaces but a folder is included in the seq list of objects being sorted at return sorted(seq, key=attrgetter(*attr))

This folder object returns None for the various attributes (date, filesize, etc) causing the error.

Removing the folder object from the seq list seems to have fixed the issue without further consequence.

TypeError, build_attrs() got an unexpected keyword argument 'type' in Django 1.11

When I want to create model with FileBrowseField in admin using Django 1.11 it throws me:

File "/home/user/.virtualenvs/project/local/lib/python2.7/site-packages/filebrowser/fields.py" in render
  42.         final_attrs = self.build_attrs(attrs, type=self.input_type, name=name)

Exception Type: TypeError at /admin/rr_website/staticfile/add/
Exception Value: build_attrs() got an unexpected keyword argument 'type'

I'm using newest 3.7.0 version and python 2.7.

When is TinyMCE V5 supported?

I used TinyMCE(V5) and Django-filebrowser-no-grappelli(v3.8.0), they can't work well, and I've spent a lot of time on it.Because TinyMCE V5 is not supported yet. Now, a new pull request (support for TinyMCE v5) submitted by alan-hicks . I added the changes to my project and it worked.

Upload template points at minified JS file that was removed at django 3.2

admin/js/collapse.min.js is referenced here:

<script type="text/javascript" src="{% static "admin/js/collapse.min.js" %}"></script>

This minified file was removed at django 3.2:
https://docs.djangoproject.com/en/3.2/releases/3.2/#id1

Minified JavaScript files are no longer included with the admin. If you require these files to be minified, consider using a third party app or external build tool. The minified vendored JavaScript files packaged with the admin (e.g. jquery.min.js) are still included.

It would be forwards and backwards compatible to instead reference the unminified version here.

Incompatible changes in django 3.1.2

Django 3.1.2 changed the changelist.css to flex layout. This destroys the layout of the filebrowser admin changelist. This is especially annoying in the popup windows like tinymce.

django3_1_1(Before: Django 3.1.1)

django3_1_2(After: Django3.1.2)

Showing multiple sites in admin page

Hello!
I was wondering if we have the option to show different sites in the admin panel.
I'm currently creating two sites, with different names, so I add these two urls:

    a_site = FileBrowserSite(...) 
    b_site = FileBrowserSite(...) 
    urlpatterns =  [
            path(A_BROWSER_URL, a_site.urls),
            path(B_BROWSER_URL, b_site.urls)
    ]

I can manually access the urls (*/browse, etc..) of the two filebrowser sites with this configuration.

I was looking at merge request #5 and I see we have the FileBrowser section in the admin page. The link redirects to the first site of the two created before, but I would like to have a link for each site. Is this possible?

Thanks!

ImproperlyConfigured at /admin/

The included urlconf module 'filebrowser.urls' from '../local/lib/python2.7/site-packages/django_filebrowser_no_grappelli-3.5.7-py2.7.egg/filebrowser/urls.pyc doesn't have any patterns in it

Local URI issue

I'm developing a system in which I need the Django site to interface with a Unity-developed application, where the Django app acts, among other things, as a provider for some images. I found this plugin for uploading and managing the images, but I'm having some issues with displaying the images within the Filebrowser views. Basically, it's adding the URL stored in the database to the whole path to the current view, so instead of linking and displaying the image at 'localhost/static/foo/bar.png', if I'm at 'localhost/admin/users/1/change', it tries to display a theoretical image at 'localhost/admin/users/1/static/foo/bar.png'. Attached you can find a real example of this.

image

Thanks for your attention, and I look forward to your answer.

Not technically 1.9 compliant

You have a number of RemovedInDjango110Warning messages:

RemovedInDjango110Warning: render() must be called with a dict, not a RequestContext. return template.render(context, request)

you use RequestContext in a number of places.

and:

sites.py:340: RemovedInDjango110Warning: The current_app argument of RequestContext is deprecated. Set the current_app attribute of its request instead. }, request), context_instance=Context(request, current_app=self.name))

also sill need to fix SubfieldBase warnings. the pull request that claims to fix this doesn't work.

Thanks for the great work... I have spent some time trying to figure out how to fix these, but don't really have a clue... hopefully you can find some time to make the changes.

Page not found / table filebrowser_filebrowser doesn't exist

Hello,

I'm using django-filebrowser-no-grappelli version 3.8.0 with Django 3.2.4.

I have path('admin/filebrowser/', site.urls), in my urls.py.

At some point recently (I cannot say precisely when, I just discovered it) it the admin 'browse' section stopped working. It used to work when I first installed months ago.

When I go to admin/filebrowser/browse/ I get

<h1>Page not found <span>(404)</span></h1>
Request Method: | GET
-- | --
/admin/filebrowser/browse/
django.contrib.admin.sites.catch_all_view

When I launch python manage.py dumpdata > db.json I get:

CommandError: Unable to serialize database: (1146, "Table 'NMS_database.filebrowser_filebrowser' doesn't exist")

What can the reason be?

ResourceWarning — file objects are not closed properly

Steps:

  • run app with python warnings enabled (python3 -Wmodule for example)
  • open filebrowser in admin, look at files
  • see many ResourceWarning

Fix: close file objects after reading or streaming their content (with statement may help, depending on the code structure)

Missing newest releases

Where is the source code for the newest releases 3.6.2 and 3.7.0... ? I'm trying to override the templates to add django-material admin support and I'm coming across TemplateSyntaxErrors, but then I realized I was using 3.5.8 templates with my currently installed 3.7.0 version. I can get the templates from the locally installed library, but I was just wondering if the remote provider changed or if this library is no longer being maintained? Thanks in advance for your time.

I cannot import filebrowser module into django Installed Apps

Hello

i am using djang-tinymce-lite-4 wysiwyg editor

and i wanna import file upload to tinymce editor!

but i cannot import the 'filebrowser' module into my project

what is the problem and what can i do ?

below are screenshots of errors

[02/Jan/2019 10:57:41] "GET / HTTP/1.1" 302 0
Internal Server Error: /winbook_insert/
Traceback (most recent call last):
File "C:\Users\jjunest\AppData\Local\Programs\Python\Python37\lib\site-packages\django\template\utils.py", line 64, in getitem
return self._engines[alias]
KeyError: 'django'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\jjunest\AppData\Local\Programs\Python\Python37\lib\site-packages\filebrowser\utils.py", line 18, in
from PIL import Image
ModuleNotFoundError: No module named 'PIL'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\jjunest\AppData\Local\Programs\Python\Python37\lib\site-packages\django\template\backends\django.py", line 121, in get_package_libraries
module = import_module(entry[1])
File "C:\Users\jjunest\AppData\Local\Programs\Python\Python37\lib\importlib_init_.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 1006, in _gcd_import
File "", line 983, in _find_and_load
File "", line 967, in _find_and_load_unlocked
File "", line 677, in _load_unlocked
File "", line 728, in exec_module
File "", line 219, in _call_with_frames_removed
File "C:\Users\jjunest\AppData\Local\Programs\Python\Python37\lib\site-packages\filebrowser\templatetags\fb_versions.py", line 8, in
from filebrowser.base import FileObject
File "C:\Users\jjunest\AppData\Local\Programs\Python\Python37\lib\site-packages\filebrowser\base.py", line 16, in
from filebrowser.utils import path_strip, process_image
File "C:\Users\jjunest\AppData\Local\Programs\Python\Python37\lib\site-packages\filebrowser\utils.py", line 20, in
import Image
ModuleNotFoundError: No module named 'Image'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\jjunest\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\handlers\exception.py", line 35, in inner
response = get_response(request)
File "C:\Users\jjunest\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\handlers\base.py", line 128, in _get_response
response = self.process_exception_by_middleware(e, request)
File "C:\Users\jjunest\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\handlers\base.py", line 126, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "C:\Users\jjunest\AppData\Local\Programs\Python\Python37\lib\site-packages\django\contrib\auth\decorators.py", line 21, in _wrapped_view
return view_func(request, *args, **kwargs)
File "C:\DjangoProject\TheaterWin\TheaterWinBook\views.py", line 193, in winbook_insert
return render(request, 'TheaterWinBook/winbook_insert.html', {'form': form}) # 템플릿 파일 경로 지정, 데이터 전달
File "C:\Users\jjunest\AppData\Local\Programs\Python\Python37\lib\site-packages\django\shortcuts.py", line 36, in render
content = loader.render_to_string(template_name, context, request, using=using)
File "C:\Users\jjunest\AppData\Local\Programs\Python\Python37\lib\site-packages\django\template\loader.py", line 61, in render_to_string
template = get_template(template_name, using=using)
File "C:\Users\jjunest\AppData\Local\Programs\Python\Python37\lib\site-packages\django\template\loader.py", line 12, in get_template
engines = _engine_list(using)
File "C:\Users\jjunest\AppData\Local\Programs\Python\Python37\lib\site-packages\django\template\loader.py", line 66, in _engine_list
return engines.all() if using is None else [engines[using]]
File "C:\Users\jjunest\AppData\Local\Programs\Python\Python37\lib\site-packages\django\template\utils.py", line 88, in all
return [self[alias] for alias in self]
File "C:\Users\jjunest\AppData\Local\Programs\Python\Python37\lib\site-packages\django\template\utils.py", line 88, in
return [self[alias] for alias in self]
File "C:\Users\jjunest\AppData\Local\Programs\Python\Python37\lib\site-packages\django\template\utils.py", line 79, in getitem
engine = engine_cls(params)
File "C:\Users\jjunest\AppData\Local\Programs\Python\Python37\lib\site-packages\django\template\backends\django.py", line 25, in init
options['libraries'] = self.get_templatetag_libraries(libraries)
File "C:\Users\jjunest\AppData\Local\Programs\Python\Python37\lib\site-packages\django\template\backends\django.py", line 43, in get_templatetag_libraries
libraries = get_installed_libraries()
File "C:\Users\jjunest\AppData\Local\Programs\Python\Python37\lib\site-packages\django\template\backends\django.py", line 108, in get_installed_libraries
for name in get_package_libraries(pkg):
File "C:\Users\jjunest\AppData\Local\Programs\Python\Python37\lib\site-packages\django\template\backends\django.py", line 125, in get_package_libraries
"trying to load '%s': %s" % (entry[1], e)
django.template.library.InvalidTemplateLibrary: Invalid template library specified. ImportError raised when trying to load 'filebrowser.templatetags.fb_versions': No module named 'Image'
[2019-01-02 10:57:41,590] exception: ERROR - Internal Server Error: /winbook_insert/
Traceback (most recent call last):
File "C:\Users\jjunest\AppData\Local\Programs\Python\Python37\lib\site-packages\django\template\utils.py", line 64, in getitem
return self._engines[alias]
KeyError: 'django'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\jjunest\AppData\Local\Programs\Python\Python37\lib\site-packages\filebrowser\utils.py", line 18, in
from PIL import Image
ModuleNotFoundError: No module named 'PIL'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\jjunest\AppData\Local\Programs\Python\Python37\lib\site-packages\django\template\backends\django.py", line 121, in get_package_libraries
module = import_module(entry[1])
File "C:\Users\jjunest\AppData\Local\Programs\Python\Python37\lib\importlib_init_.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 1006, in _gcd_import
File "", line 983, in _find_and_load
File "", line 967, in _find_and_load_unlocked
File "", line 677, in _load_unlocked
File "", line 728, in exec_module
File "", line 219, in _call_with_frames_removed
File "C:\Users\jjunest\AppData\Local\Programs\Python\Python37\lib\site-packages\filebrowser\templatetags\fb_versions.py", line 8, in
from filebrowser.base import FileObject
File "C:\Users\jjunest\AppData\Local\Programs\Python\Python37\lib\site-packages\filebrowser\base.py", line 16, in
from filebrowser.utils import path_strip, process_image
File "C:\Users\jjunest\AppData\Local\Programs\Python\Python37\lib\site-packages\filebrowser\utils.py", line 20, in
import Image
ModuleNotFoundError: No module named 'Image'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\jjunest\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\handlers\exception.py", line 35, in inner
response = get_response(request)
File "C:\Users\jjunest\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\handlers\base.py", line 128, in _get_response
response = self.process_exception_by_middleware(e, request)
File "C:\Users\jjunest\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\handlers\base.py", line 126, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "C:\Users\jjunest\AppData\Local\Programs\Python\Python37\lib\site-packages\django\contrib\auth\decorators.py", line 21, in _wrapped_view
return view_func(request, *args, **kwargs)
File "C:\DjangoProject\TheaterWin\TheaterWinBook\views.py", line 193, in winbook_insert
return render(request, 'TheaterWinBook/winbook_insert.html', {'form': form}) # 템플릿 파일 경로 지정, 데이터 전달
File "C:\Users\jjunest\AppData\Local\Programs\Python\Python37\lib\site-packages\django\shortcuts.py", line 36, in render
content = loader.render_to_string(template_name, context, request, using=using)
File "C:\Users\jjunest\AppData\Local\Programs\Python\Python37\lib\site-packages\django\template\loader.py", line 61, in render_to_string
template = get_template(template_name, using=using)
File "C:\Users\jjunest\AppData\Local\Programs\Python\Python37\lib\site-packages\django\template\loader.py", line 12, in get_template
engines = _engine_list(using)
File "C:\Users\jjunest\AppData\Local\Programs\Python\Python37\lib\site-packages\django\template\loader.py", line 66, in _engine_list
return engines.all() if using is None else [engines[using]]
File "C:\Users\jjunest\AppData\Local\Programs\Python\Python37\lib\site-packages\django\template\utils.py", line 88, in all
return [self[alias] for alias in self]
File "C:\Users\jjunest\AppData\Local\Programs\Python\Python37\lib\site-packages\django\template\utils.py", line 88, in
return [self[alias] for alias in self]
File "C:\Users\jjunest\AppData\Local\Programs\Python\Python37\lib\site-packages\django\template\utils.py", line 79, in getitem
engine = engine_cls(params)
File "C:\Users\jjunest\AppData\Local\Programs\Python\Python37\lib\site-packages\django\template\backends\django.py", line 25, in init
options['libraries'] = self.get_templatetag_libraries(libraries)
File "C:\Users\jjunest\AppData\Local\Programs\Python\Python37\lib\site-packages\django\template\backends\django.py", line 43, in get_templatetag_libraries
libraries = get_installed_libraries()
File "C:\Users\jjunest\AppData\Local\Programs\Python\Python37\lib\site-packages\django\template\backends\django.py", line 108, in get_installed_libraries
for name in get_package_libraries(pkg):
File "C:\Users\jjunest\AppData\Local\Programs\Python\Python37\lib\site-packages\django\template\backends\django.py", line 125, in get_package_libraries
"trying to load '%s': %s" % (entry[1], e)
django.template.library.InvalidTemplateLibrary: Invalid template library specified. ImportError raised when trying to load 'filebrowser.templatetags.fb_versions': No module named 'Image'
[02/Jan/2019 10:57:49] "GET /winbook_insert/ HTTP/1.1" 500 210603
Not Found: /favicon.ico
[2019-01-02 10:57:50,822] base: WARNING - Not Found: /favicon.ico
[02/Jan/2019 10:57:50] "GET /favicon.ico HTTP/1.1" 404 8907

Incompatibility with django 3.1.2

Django 3.1.2 changed the changelist.css to flex layout. This destroys the layout of the filebrowser admin changelist. This is especially annoying in the popup windows like tinymce.

django3_1_1(Before: Django 3.1.1)

django3_1_2(After: Django3.1.2)

String default for FileBrowserField not working

Clone of sehmaschine#358, I decided to open it here since it looks more actively maintained.

A string default for FileBrowserField does not work since it looks for .path on a string, at least on PostgreSQL:

def get_prep_value(self, value):
if not value:
return value
return value.path

Of course this fails with:

AttributeError: 'str' object has no attribute 'path'

Other examples can be found in the original issue linked.

I'll submit the same PR, but maybe there is a better solution to this problem.

Reverse for 'app_list' with keyword arguments '{'app_label': 'filebrowser'}' not found

Hello, I am having trouble installing django-filebrowser-no-grappelli.
I've followed the steps to install it but if I go to http://127.0.0.1:8000/admin/filebrowser/browse/, I get the following error :

NoReverseMatch at /admin/filebrowser/browse/
Reverse for 'app_list' with keyword arguments '{'app_label': 'filebrowser'}' not found. 1 pattern(s) tried: ['admin/(?P<app_label>store|taggit)/$']

I've been looking for a solution for hours but I am unable to understand this error...
I am using Django 2.2.2 and django-filebrowser-no-grappelli 3.8.0.
Sorry if this is the wrong place to ask, feel free to redirect my request somewhere else.

Delete Checkbox, how to show that?

Somehow delete checkbox is not shown in the chanagelist, I am using FileBrowser 3.6.1 with django 1.8.7. Anybody has any clues as to what to look into?

./manage.py dumpdata fails for FileBrowseField with Django2.0 and SQLite

Using Django 2.0.1, I can't dump FileBrowseFields:

(venv) ➜  backend git:(master) ✗ ./manage.py dumpdata some.Model --indent=2 > dump.json
CommandError: Unable to serialize database: 'FileBrowseField' object has no attribute '_get_val_from_obj'
Exception ignored in: <generator object cursor_iter at 0x1065b0048>
Traceback (most recent call last):
  File "/w/some-project/backend/venv/lib/python3.6/site-packages/django/db/models/sql/compiler.py", line 1460, in cursor_iter
    cursor.close()
sqlite3.ProgrammingError: Cannot operate on a closed database.

Installation errors

When installing in a virtualenv with python 3.4.2.

$ pip install git+git://github.com/smacker/django-filebrowser-no-grappelli.git#egg=django-filebrowser


Installing collected packages: django-filebrowser
  Running setup.py install for django-filebrowser

      File "/Users/shacker/Sites/virtualenvs/ccademo3/lib/python3.4/site-packages/filebrowser/tests/test_sites.py", line 145
        permissions_file = oct(os.stat(test.testfile.path_full).st_mode & 0777)
                                                                             ^
    SyntaxError: invalid token

      File "/Users/shacker/Sites/virtualenvs/ccademo3/lib/python3.4/site-packages/filebrowser/tests/test_versions.py", line 184
        permissions_file = oct(os.stat(os.path.join(settings.MEDIA_ROOT, "fb_test_directory/_versions/fb_tmp_dir/fb_tmp_dir_sub/testimage_large.jpg")).st_mode & 0777)
                                                                                                                                                                    ^
    SyntaxError: invalid token

Successfully installed django-filebrowser
Cleaning up...

Looks like installation was still successfull, though the syntax errors make it appear like it wasn't.

This looks like the most promising no-grappelli fork

More recent than /wardi/django-filebrowser-no-grappelli and hopefully more actively maintained. :)

I'm posting this as an issue just to test the water. If I get a reply then I've got some issues and hopefully some pull requests. If not then I'll try forking it myself.

Any idea why you aren't appearing in Github search results for 'django-filebrowser-no-grappelli'?

Storage mixin does not work with boto3

Hello! To use this filebrowser with django-tinymce and S3 storage for uploaded files, I combined S3Boto3Storage backend with your S3BotoStorageMixin.

I got this exception:

AttributeError
filebrowser.decorators.path_exists..decorator
's3.Bucket' object has no attribute 'list'

Possible fix for Django 2.1

I couldn't get the dev server to run django-filebrowser-no-grappelli with Django 2.1 and saw that you advertise Django 2.0 only. I made a couple of small changes in sites.py and it seems to work now with Django 2.1.9. Contributing to your project is way above my pay-grade and I don't use Git so I'll just point out what I did ...

Firstly, adopted the new Django incantation for importing re_path instead of url. Lines 207 to 210 are new. No other changes in get_urls(). This should be OK for Django 2.2 as well with any luck.
#sites.py
205 def get_urls(self):
206 "URLs for a filebrowser.site"
207 try:
208 from django.urls import re_path as url
209 except ImportError:
210 from django.conf.urls import url
211 # filebrowser urls (views)
212 urlpatterns = [
213 url(r'^browse/$', path_exists(self, filebrowser_view(self.browse)), name="fb_browse"),

Secondly, removed self.name from the return
#sites.py
269 @Property
270 def urls(self):
271 "filebrowser.site URLs"
272 return self.get_urls(), self.app_name #, self.name

I have no idea how this may affect anything else but it works for me.

s3 storage + tinymce for uploaded images

Hi there--

My application is setup to work with django-tinymce4-lite and it works great when using offline/local media storage. What i mean by that is if I choose to upload an image, the image gets uploaded to media/uploads, including several thumbnail 'versions' that get saved to media/_versions.

When I enable s3 as my media storage location, the image files are getting uploaded to the uploads folder in my bucket correctly (folder is auto created at upload time), however thumbnails are not generated alongside, and in fact, after an upload, the _versions folder does not get created at all.

While I'm able to insert these images after upload using the image insert button, it's a bit frustrating in that unless the image has a descriptive filename, its impossible to tell which image is which without that image preview.

Any help would be greatly appreciated!

Here are the relevant settings regarding tinymce and s3 configuration:

# Media config
USE_S3 = int(os.environ.get('USE_S3', 0))
if USE_S3:
    AWS_ACCESS_KEY_ID = os.environ.get('AWS_ACCESS_ID')
    AWS_SECRET_ACCESS_KEY = os.environ.get('AWS_SECRET_KEY')
    AWS_STORAGE_BUCKET_NAME = os.environ.get('AWS_STORAGE_BUCKET_NAME')
    AWS_DEFAULT_ACL = 'public-read'
    AWS_S3_CUSTOM_DOMAIN = f'{AWS_STORAGE_BUCKET_NAME}.s3.amazonaws.com'
    AWS_S3_OBJECT_PARAMETERS = {'CacheControl': 'max-age=86400'}
    AWS_PRELOAD_METADATA = True
    AWS_QUERYSTRING_AUTH = False
    # s3 media config
    MEDIA_LOCATION = 'media'
    MEDIA_URL = f'https://{AWS_S3_CUSTOM_DOMAIN}/{MEDIA_LOCATION}/'
    DEFAULT_FILE_STORAGE = 'config.storage_backends.MediaStorage'
else:
    MEDIA_URL = '/media/'
    MEDIA_ROOT = os.path.join(BASE_DIR, 'media')


# TinyMCE-lite config
TINYMCE_DEFAULT_CONFIG = {
    'selector': 'textarea',
    'theme': 'modern',
    'plugins': 'link image preview codesample contextmenu table code lists colorpicker textcolor',
    'toolbar1': 'formatselect | bold italic underline | forecolor backcolor | alignleft aligncenter alignright alignjustify '
               '| bullist numlist | outdent indent | table | link image | codesample | preview code | fontsizeselect fontsize ',
    'content_css': 'https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css',
    'contextmenu': 'formats | link image',
    'menubar': False,
    'inline': False,
    'statusbar': True,
    'width': 'auto',
    'height': 360,
}

Here is storage_backends.py:

from storages.backends.s3boto3 import S3Boto3Storage
from django.conf import settings
from django.utils import timezone


class MediaStorage(S3Boto3Storage):
    location = settings.MEDIA_LOCATION
    default_acl = 'private'
    file_overwrite = False
    #custom_domain = False
    isfilecached = {}

    def isdir(self, name):
        if not name:  # Empty name is a directory
            return True

        if self.isfile(name):
            return False

        return True

    def isfile(self, name):
        if len(name.split('.')) > 1:
            return True
        try:
            name = self._normalize_name(self._clean_name(name))
            if self.isfilecached.get(name) is not None:
                return self.isfilecached.get(name)

            f = S3Boto3StorageFile(name, 'rb', self)
            if "directory" in f.obj.content_type:
                isfile = False
            else:
                isfile = True
        except Exception:
            isfile = False
        self.isfilecached[name] = isfile
        return isfile

    def move(self, old_file_name, new_file_name, allow_overwrite=False):

        if self.exists(new_file_name):
            if allow_overwrite:
                self.delete(new_file_name)
            else:
                raise "The destination file '%s' exists and allow_overwrite is False" % new_file_name

        old_key_name = self._encode_name(self._normalize_name(self._clean_name(old_file_name)))
        new_key_name = self._encode_name(self._normalize_name(self._clean_name(new_file_name)))

        k = self.bucket.meta.client.copy(
            {
                'Bucket': self.bucket.name,
                'Key': new_key_name
            },
            self.bucket.name,
            old_key_name
        )

        if not k:
            raise "Couldn't copy '%s' to '%s'" % (old_file_name, new_file_name)

        self.delete(old_file_name)

    def makedirs(self, name):
        name = self._normalize_name(self._clean_name(name))
        return self.bucket.meta.client.put_object(Bucket=self.bucket.name, Key=f'{name}/')

    def rmtree(self, name):
        name = self._normalize_name(self._clean_name(name))
        delete_objects = [{'Key': f"{name}/"}]

        dirlist = self.listdir(self._encode_name(name))
        for item in dirlist:
            for obj in item:
                obj_name = f"{name}/{obj}"
                if self.isdir(obj_name):
                    obj_name = f"{obj_name}/"
                delete_objects.append({'Key': obj_name})
        self.bucket.delete_objects(Delete={'Objects': delete_objects})

    def path(self, name):
        return name

    def listdir(self, name):
        directories, files = super().listdir(name)
        if '.' in files:
            files.remove('.')
        return directories, files

    def exists(self, name):
        if self.isdir(name):
            return True
        else:
            return super().exists(name)

    def get_modified_time(self, name):
        try:
            # S3 boto3 library requires that directorys have the trailing slash
            if self.isdir(name):
                name = f'{name}/'
            modified_date = super().get_modified_time(name)
        except Exception:
            modified_date = timezone.now()
        return modified_date

    def size(self, name):
        try:
            # S3 boto3 library requires that directorys have the trailing slash
            if self.isdir(name):
                name = f'{name}/'
            size = super().size(name)
        except Exception:
            size = 0
        return size

Config documentation

I'm a little bit lost on documentation here. There seems to be references to setting something called site.storage.location and site.directory, but all the documentation tells me is that I should set them.

I just for the life of me cant work out how.

I've put site.storage.location="" in settings.py and it spits it out and tells me it doesnt know what site is. I've tried settings SITE_ID=1 and activating sites in django settings. No joy. Google doesnt seem to know, and I cant find any examples of how to configure this.

I'm sure the answer is in somebodies head , out there!

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.