Reputation: 785
I'm new to Django and trying to figure out how to override all of my textarea fields in my Admin Model Forms. I saw this in the django-summernote docs:
from django_summernote.admin import SummernoteModelAdmin
# Apply summernote to all TextField in model.
class SomeModelAdmin(SummernoteModelAdmin): # instead of ModelAdmin
...
But I'm not sure what should replace the ellipses. Is there a way to do this for all textareas in Admin at once or does this need to be applied to each Model?
Thanks!
Upvotes: 1
Views: 1530
Reputation: 3008
Actually, ellipses
means custom admin codes for your models.
https://docs.djangoproject.com/en/1.8/ref/contrib/admin/#modeladmin-options
So, if you don't have any custom values for your ModelAdmin
, then just put admin.site.register(Question, SummernoteModelAdmin)
without own class declaration.
Upvotes: 1
Reputation: 785
All I needed to do was add the following to my admin.py script:
from django_summernote.admin import SummernoteModelAdmin
class QuestionAdmin(SummernoteModelAdmin):
pass # you can add more overrides to the Admin Form but this is all that is needed for overriding the Textfield
admin.site.register(Question, QuestionAdmin)
This will override the Admin form to add Summernote in place of the Textfields and register the new Admin form. I was missing adding QuestionAdmin to the admin.site.register command.
Upvotes: 0