i am integrating some apps to make a bigger project but the problem is when i try insert ckeditor in html login page it is not showing. for this reason i tried to make separate app is to see whats going on here. i am showing you the code in detail.
editing/settings.py:
..........
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'editor',
'ckeditor_uploader',
'ckeditor',
]
TEMPLATES = [
{
'DIRS': [os.path.join(BASE_DIR,'templates')],........
.....................
STATIC_URL = 'editor/static/'
STATIC_ROOT='editor/static/'
CKEDITOR_UPLOAD_PATH='editor/static/media/'
editing/urls.py:
from django.contrib import admin
from django.urls import path, include
from django.conf import settings
from django.conf.urls.static import static
urlpatterns = [
path('admin/', admin.site.urls),
path('',include('editor.urls')),
path('ckeditor/',include('ckeditor_uploader.urls')),
] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
in this case, my static folder is in editor/static when i execute python manage.py collectstatic and ckeditor folder is in editor/static directory also.
editor/models.py:
from django.db import models
from ckeditor_uploader.fields import RichTextUploadingField
# Create your models here.
class Post(models.Model):
title=models.CharField(max_length=255)
body=models.CharField(max_length=2000)
description=RichTextUploadingField()
def __str__(self):
return self.title
editor/admin.py:
from django.contrib import admin
from .models import Post
admin.site.register(Post)
when i execute python manage.py makemigrations and python manage.py migrate, ckeditor can be seen in locahost:8000/admin’s new post section perfectly. then i tried to make templates.
base.html:
{% load static %}
Django blog
home.html:
{% extends ‘base.html’ %}
{% block content %}
New post
<form action="" method="post"enctype=“multipart/form-data”>
{{ form.media|safe }}
{{ form.as_p }}
{% endblock content %}
and then i have created a html file editor/urls.py:
from django.urls import path
from .views import HomePageView
urlpatterns=[
path('',HomePageView.as_view(), name='home'),
]
and here is the editor/views.py also:
from django.views.generic import TemplateView
from .models import Post
class HomePageView(TemplateView):
model=Post
template_name='home.html'
fields=['title','body']
i just want to see a simple page of showing new html post editor with ckeditor toolbar in it. it’s just for seeing what’s wrong and why my ckeditor toolbar is not showing in my html file. when i run python manage.py runserver there is no error showing and the html page is showing django post and new post and only the save button. it can’t render the form of the django’s new post. css style is rendered because the django post and new post has the desired color and font. but why it is not rendering the new post form with ckeditor toolbar?
i am still learning and this problem is eating me up. thanx in advance