Hi,
Django view dont render csrf tag within template form, you should check doc in warning part
And look at the additional way to resolve your problem.
On Thu, Dec 12, 2019, 16:45 হজমুলা খান <needlestrock@gmail.com> wrote:
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 adminfrom django.urls import path, includefrom django.conf import settingsfrom django.conf.urls.static import staticurlpatterns = [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 modelsfrom 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.titleeditor/admin.py:from django.contrib import adminfrom .models import Postadmin.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 %}<html><head><title>Django blog</title>rel="stylesheet"><link href="{% static 'admin/css/base.css' %}" rel="stylesheet"></head><body><div><header><div class="nav-left"><h1><a>Django blog</a></h1></div></header>{% block content %}{% endblock content %}</div></body></html>home.html:{% extends 'base.html' %}{% block content %}<h1>New post</h1><form action="" method="post"enctype="multipart/form-data">{% csrf_token %}{{ form.media|safe }}{{ form.as_p }}<input type="submit" value="Save" /></form>{% endblock content %}and then i have created a html file editor/urls.py:from django.urls import pathfrom .views import HomePageViewurlpatterns=[path('',HomePageView.as_view(), name='home'),]and here is the editor/views.py also:from django.views.generic import TemplateViewfrom .models import Postclass HomePageView(TemplateView):model=Posttemplate_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
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/b8c48a91-b67c-4da0-8ce3-b301798a3851%40googlegroups.com.
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAP5HUWpVhjVBiVMJcAqSpnYxxte0gw4TYSTBr3xpagH0QYotKw%40mail.gmail.com.
No comments:
Post a Comment