I have a model for entering articles, and I have an excerpt and description field. If the user wants to send an image, then I have a separate ImageField, which has a default default file browser.
I tried using django-filebrowser , but I don’t like the fact that it requires django-grappelli and I don’t necessarily need a utility to load flash memory. Can anyone recommend a tool in which I can control image loading and basically replace the file view provided by django using the image browser?
In the future, I probably want it to handle image size and determine default image sizes for certain types of articles.
Edit: Now I'm trying adminfiles , but I am having problems installing it. I grabbed it and added python to my path, added it to INSTALLED_APPS, created databases for it, uploaded the image. I followed the instructions to modify my model to specify adminfiles_fields and registered, but was not used in my admin, here is my admin.py for articles:
from django.contrib import admin from django import forms from articles.models import Category, Entry from tinymce.widgets import TinyMCE from adminfiles.admin import FilePickerAdmin class EntryForm( forms.ModelForm ): class Media: js = ['/media/tinymce/tiny_mce.js', '/media/tinymce/load.js']
Here is my input model:
class Entry( models.Model ): LIVE_STATUS = 1 DRAFT_STATUS = 2 HIDDEN_STATUS = 3 STATUS_CHOICES = ( ( LIVE_STATUS, 'Live' ), ( DRAFT_STATUS, 'Draft' ), ( HIDDEN_STATUS, 'Hidden' ), ) status = models.IntegerField( choices=STATUS_CHOICES, default=LIVE_STATUS ) tags = TagField() categories = models.ManyToManyField( Category ) title = models.CharField( max_length=250 ) excerpt = models.TextField( blank=True ) excerpt_html = models.TextField(editable=False, blank=True) body_html = models.TextField( editable=False, blank=True ) article_image = models.ImageField(blank=True, upload_to='upload') body = models.TextField() enable_comments = models.BooleanField(default=True) pub_date = models.DateTimeField(default=datetime.datetime.now) slug = models.SlugField(unique_for_date='pub_date') author = models.ForeignKey(User) featured = models.BooleanField(default=False) def save( self, force_insert=False, force_update= False): self.body_html = markdown(self.body) if self.excerpt: self.excerpt_html = markdown( self.excerpt ) super( Entry, self ).save( force_insert, force_update ) class Meta: ordering = ['-pub_date'] verbose_name_plural = "Entries" def __unicode__(self): return self.title
Edit # 2: To clarify that I moved the media files to my media path, and they really display the image area, I can upload the text, the << <<<image>>> tag is inserted into my editable MarkItUp w / Markdown area, but it doesn’t appears in the preview of MarkItUp - maybe I just need to apply |upload_tags for this preview. I will try to add it to my template, which will also post the article.