MyGit

miguelramos/django-media-manager

Fork: 31 Star: 42 (更新于 2024-11-17 00:14:11)

license: NOASSERTION

Language: Python .

Django Filebrowser Updated to 1.8

最后发布版本: v3.5.2 ( 2019-07-29 18:03:31)

GitHub网址

WITHOUT TIME TO MAINTAIN

At the moment i'm without time to maintain this great project. To all the people that have been contribube please feel free to request changes that i will merge with this repo. To anyone who wants to maintain this project just pm a message.

Changelog

08-03-2017 v3.5.2

  • Support Django 2+

08-03-2017 v3.5.0

  • Removed flash uploader. Instead of this added drag’n’drop file uploads with image previews.

06-10-2016 v3.4.1

  • Mandatory django version >= 1.8

25-08-2014 v3.4.0

  • Uses Pillow now.
  • Python 3 only now.
  • Integration with the Six Foot Chirping Malachite Sunbird working.

02-07-2013

  • Refactor and resolved an issue on window.opener event.
  • Refactor FB_Redactor plugin.

28-06-2013

  • Support for django-suit
  • Support for django-suit-ckeditor
  • Support for django-suit-redactor
  • Support for custom user model
  • Mandatory django version higher 1.5

Basic Installation

pip install django-media-manager
or
pip install git+https://github.com/miguelramos/django-media-manager.git
  • Add filebrowser to INSTALLED_APPS before django.contrib.admin.
  • Add the following line before the admin URLS:
  •   (r'^admin/filebrowser/', include('filebrowser.urls'))
    
  • Collect static files
  • Add uploads/ folder to media folder or customize this setting

Suit support

The application have support for django-suit template. To use it add on your settings files the following config:

FILEBROWSER_SUIT_TEMPLATE = True

Filebrowser will now use templates for django suit.

Suit CKEditor/Redactor

To use filebrowser on django-suit-ckeditor or django-suit-redactor please follow the example bellow:

#models.py

from django.db import models
from filebrowser.fields import FileBrowseField

class MediaPublication(models.Model):
    ckeditor = models.TextField(help_text='Editor CKEditor')
    redactor = models.TextField(help_text='Editor Redactor')
    image = FileBrowseField("Image", max_length=200, blank=True, null=True)
    image_initialdir = FileBrowseField("Image (Initial Directory)", max_length=200, directory="images/", blank=True, null=True)
    image_extensions = FileBrowseField("Image (Extensions)", max_length=200, extensions=['.jpg'],
                               help_text="Only jpg-Images allowed.", blank=True, null=True)
    image_format = FileBrowseField("Image (Format)", max_length=200, format='Image', blank=True, null=True)
    pdf = FileBrowseField("PDF", max_length=200, directory="documents/", extensions=['.pdf'], format='Document',
                  blank=True, null=True)

    class Meta:
	ordering = ['image',]
	verbose_name = 'publication'
	verbose_name_plural = 'publications'

To use on admin you need to do some litle tweeks:

#admin.py
from django.contrib import admin
from django.forms import ModelForm, Media
from suit_ckeditor.widgets import CKEditorWidget
from suit_redactor.widgets import RedactorWidget

from .models import MediaPublication


class Editor(ModelForm):
    class Meta:
	widgets = {
    	'ckeditor': CKEditorWidget(editor_options={'startupFocus': True}),
    	'redactor': RedactorWidget(editor_options={
        	'lang': 'en',
        	'plugins': ['filebrowser']
    	}),
	}

    class Media:
	js = ('filebrowser/js/FB_CKEditor.js', 'filebrowser/js/FB_Redactor.js')
	css = {
    	'all': ('filebrowser/css/suit-filebrowser.css',)
	}

class AdminPublication(admin.ModelAdmin):
    form = Editor

    fieldsets = (
	(None, {
    	'classes': ('suit-tab suit-tab-media',),
    	'fields': ['image', 'image_initialdir', 'image_extensions', 'image_format', 'pdf'],
	}),
	('CKEditor', {
    	'classes': ('full-width',),
    	'fields': ('ckeditor',)
	}),
	('Redactor', {
    	'classes': ('full-width',),
    	'fields': ('redactor',)
	}),
    )

    list_display = ('thumbnail', 'image_extensions', 'pdf')
    suit_form_tabs = (('media', 'Media'),)

    def thumbnail(self, obj):
	if obj.image:
    	return '<img src="%s" />' % obj.image.url_thumbnail
	else:
    	return ""
    thumbnail.allow_tags = True


admin.site.register(MediaPublication, AdminPublication)

The most important things are on ModelForm (Media and Widgets). To use browser on CKEditor and have the button to navigate on filebrowser you only need to add the js file to Media

For Redactor you will have to add the plugin option on the widget (plugin name is mandatory - filebrowser ) and add the css and js file to media.

That's it you are now ready to send all kind of files to ckeditor or redactor.

Screenshots

TODO

Please this is a work in progress. If you have ideas or want to make it better please fel free to pull requests.

  • Add more options on thumbs sizes

More Info

You can find the original documentation of django-filebrowser and all settings in Google Code repo.

最近版本更新:(数据更新于 2024-10-18 18:29:36)

2019-07-29 18:03:31 v3.5.2

2017-03-09 00:18:34 v3.5.0

主题(topics):

ckeditor, django-filebrowser, django-suit, filebrowser, redactor, suit-ckeditor

miguelramos/django-media-manager同语言 Python最近更新仓库

2024-11-23 02:05:08 hect0x7/JMComic-Crawler-Python

2024-11-22 19:26:55 ultralytics/ultralytics

2024-11-22 18:58:34 home-assistant/core

2024-11-22 08:12:43 jxxghp/MoviePilot

2024-11-22 06:37:14 notepad-plus-plus/nppPluginList

2024-11-22 06:12:44 dagster-io/dagster