I recommend you do this on virtual-env.
1. install packages
pip install django-ckeditorpip install image (optional)
2. Set settings.py
Add ckeditor in INSTALLED_APPSINSTALLED_APPS = [ 'django.contrib.admin',
'django.contrib.auth',
... 'ckeditor',]
Add this contents end of settings.py
CKEDITOR_UPLOAD_PATH = "uploads/"
CKEDITOR_CONFIGS = { 'default': { 'toolbar': None, },
}
3. Set url.py
Add "url(r'^ckeditor/', include('ckeditor_uploader.urls'))," in urlpatternsurlpatterns = [ url(r'^admin/', admin.site.urls),
... url(r'^ckeditor/', include('ckeditor_uploader.urls')),
]
4. set models.py
Add import RichTextFieldchange "models.TextField()" to "RichTextField()"
from ckeditor.fields import RichTextField # Create your models here
class OpenCV_Post(models.Model): author = models.ForeignKey('auth.User') title = models.CharField(max_length=200) # text = models.TextField()
text = RichTextField()
5. migration!
>>python manage.py makemigrations >>python manage.py migrate
The Result on Admin
reference
https://www.youtube.com/watch?v=W8PTD7SszDI
No comments:
Post a Comment