Hi All,

I feel like there’s something simple I’m overlooking here. I can't
seem to get TinyMCE to work when I use the built-in widget from Django-
TinyMCE. This works if I uncomment the Media class at the bottom, but
the widget version of TinyMCE simply doesn't show up. Is there a
better way to tell the formfield to render with the TinyMCE widget
instead of formfield_overrides?

the admin model:

from django.db import models
from django.contrib import admin
from models import Entry
from tinymce.widgets import TinyMCE

class EntryAdmin(admin.ModelAdmin):
    list_display = ('title', 'pub_date','enable_comments',
'status')
    search_fields = ['title', 'body_html']
    list_filter = ('pub_date', 'enable_comments', 'status')
    prepopulated_fields = {"slug" : ('title',)}
    fieldsets = (
                (None, {'fields': (('title', 'status'), 'body_html', 
('pub_date',
'enable_comments'), 'tags', 'slug')}),
    )
    formfield_overrides = {
        models.TextField: {'widget': TinyMCE},
    }
    #class Media:
    #    js = ['js/tiny_mce/tiny_mce.js']
    #    js = ['js/tiny_mce/tiny_mce.js', 'js/textareas.js']

admin.site.register(Entry, EntryAdmin)

Here's the separate full model for Entry:

from django.db import models
from django.contrib.syndication.feeds import Feed
from django.contrib.sitemaps import Sitemap
#import markdown
from tagging.fields import TagField
from tagging.models import Tag

# Create your models here.

class Entry(models.Model):
    title = models.CharField(max_length=200)
    slug = models.SlugField(
        unique_for_date='pub_date',
        help_text='Automatically built from the title.'
    )
    body_html = models.TextField(blank=True)
    #body_markdown = models.TextField() #note, if you're using
Markdown, include this field, otherwise just go with body_html
    pub_date = models.DateTimeField('Date published')
    tags = TagField()
    enable_comments = models.BooleanField(default=True)
    PUB_STATUS = (
        (0, 'Draft'),
        (1, 'Published'),
    )
    status = models.IntegerField(choices=PUB_STATUS, default=0)

    class Meta:
        ordering = ('-pub_date',)
        get_latest_by = 'pub_date'
        verbose_name_plural = 'entries'

    def __unicode__(self):
        return u'%s' %(self.title)

    def get_absolute_url(self):
        return "/blog/%s/%s/" %(self.pub_date.strftime("%Y/%b/
%d").lower(), self.slug)

    #def save(self):
    #    self.body_html = markdown.markdown(self.body_markdown,
safe_mode = False)
    #     super(Entry, self).save()

    def get_previous_published(self):
        return self.get_previous_by_pub_date(status__exact=1)

    def get_next_published(self):
        return self.get_next_by_pub_date(status__exact=1)

    def get_tags(self):
        return Tag.objects.get_for_object(self)



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to