How to install django-ckeditor?

In Qaru, there are two questions about this editor , and no one answers !!!

So, I am asking how to install this Django package in my project? After these steps, I already have no mistakes, nothing, and the form remains the same. Why??

Edit: heres model

from datetime import datetime from django.db import models from django.utils.translation import ugettext_lazy as _, ugettext from ckeditor.fields import RichTextField class Newsletter(models.Model): title = models.CharField( _(u'Title'), max_length=200, help_text=_(u'Newsletter title'), ) body = RichTextField() date = models.DateField( _(u'Date'), help_text=_(u'Set date when this newsletter should be send') ) class Meta: ordering = ['title',] 

forms.py

 from models import Newsletter, Mail class NewsletterForm(forms.ModelForm): class Meta: model = Newsletter 

View:

 from newsletter.models import Newsletter, Mail from newsletter.forms import NewsletterForm, MailForm def newsletters_add(request): form = NewsletterForm() tpl = "form_newsletter.html" return render_to_response(tpl, RequestContext(request, { 'form': form, })) 

The entire form received successfully with the {{form}} tag

settings.py (project)

 CKEDITOR_MEDIA_PREFIX = "/media/ckeditor/" CKEDITOR_UPLOAD_PATH = "/www/vhosts/sender/media/newsletter/uploads/" CKEDITOR_UPLOAD_PREFIX = "http://******/media/newsletter/uploads/" CKEDITOR_RESTRICT_BY_USER = True CKEDITOR_CONFIGS = { 'default': { 'toolbar': 'Basic', }, } INSTALLED_APPS = ( 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.messages', # Uncomment the next line to enable admin documentation: # 'django.contrib.admindocs', 'django.contrib.admin', #'tagging', 'debug_toolbar', 'ckeditor', 'mailer', 'newsletter' ) 
+4
source share
2 answers

OK, sorry, I was an idiot. in the documentation there are no words about enabling JS manually somehow! so just turn it on

 <script src="http://****/media/ckeditor/ckeditor/ckeditor.js"></script> 

Are developers blind or not?

+1
source

The media necessary for the widget to display correctly must be stored as a media object. You can output the tag for the required js in your template using {{ form.media }} . The administrator should do this automatically, while in your user views you should do it yourself ... For more details see the django documentation on the media form for more information.

+6
source

Source: https://habr.com/ru/post/1332839/


All Articles