Search code examples
twitter-bootstrapdjango-adminsummernote

Django-admin-bootstapped and summernote in admin.py


I've just installed django-summernote and wish to add it on one of my admin page. I've followed the installation guide but their is no summernote display. I didn't found anything related to this.

Here is my code : In admin.py (event_app):

class StaticEventAdmin(SummernoteModelAdmin):
    fieldsets = (
        (_('Event informations'), {
            'fields': (
                'name',
                'start',
                'end',
                'description',
            )
        })
    )
admin.site.register(StaticEvent, StaticEventAdmin)

In models.py (event_app):

class StaticEvent(models.Model):
        name = models.CharField(_("Name"), max_length=255)
        start = models.DateTimeField(_("Start"))
        end = models.DateTimeField(_("End"))
        description = models.CharField(_("Description"), max_length=255)

        def __str__(self):
            return _("{0}").format(
                self.name,
            )

In urls.py (main_app):

urlpatterns = patterns('',
        ...
        (r'^summernote/', include('django_summernote.urls')),
        ...
    )

The folder structure is like this :

main_app
    urls.py
    models.py
    settings.py

    event_app
        urls.py
        models.py
        admin.py

I'm using django-admin-bootstrapped. And here the sample of settings.py to have SummernoteInplaceWidget :

SUMMERNOTE_CONFIG = {
    # Using SummernoteWidget - iframe mode
    'iframe': False,
}

So i'm wondering if there is conflict between django-bootstrapped-admin and summernote?

I have a doubt arround the main_app/urls.py, is there something else to do when we are working onto a sub-app?

I wish to have description field with summernote. Can you help me please? Regards.


Solution

  • My bad. The summernote guide explicitly say that thing :

    from django_summernote.admin import SummernoteModelAdmin
    
    # Apply summernote to all TextField in model.
    class SomeModelAdmin(SummernoteModelAdmin):
    

    And i thought any field with text are TextField (so i thought CharField was a TextField...)

    Thank you all.