Answer the question
In order to leave comments, you need to log in
Error when publishing an article, what should I do?
I'm writing my first major Django project. To implement it, I need an advanced article editor. I chose ckeditor as such. Attached it, according to the rules to the current post model. Did the migration. The editor appeared, but does not work. When you try to insert a photo, it gives an error and requires you to attach a photo using a link.
and when I try to publish an article without photos, it gives the following:
Django Version: 3.1.2 Exception Type: IntegrityError Exception Value: NOT NULL constraint failed: prosvet_logs_post.publish
class Post(models.Model):
title = models.CharField(max_length=250)
slug = models.SlugField(max_length=50, unique=True)
author = models.ForeignKey(User, on_delete=models.CASCADE,
related_name='news_posts', null=True, blank=True)
body = RichTextUploadingField()
def __str__(self):
return self.title
class Meta:
verbose_name = u"Новость"
verbose_name_plural = u"Новости"
from django.contrib import admin
from .models import Post
from prosvet_logs.models import About_us, Post, Contacts, Cooperation, Dialogs, Monologs, Projects
class PostAdmin(admin.ModelAdmin):
prepopulated_fields = {"slug": ("title",)}
admin.site.register(About_us)
admin.site.register(Post, PostAdmin)
admin.site.register(Cooperation)
admin.site.register(Contacts)
admin.site.register(Dialogs)
admin.site.register(Monologs)
admin.site.register(Projects )
urlpatterns = [
#Домашняя страница
url(r'', views.index, name ='index'),
#редактор статей
url(r'^ckeditor/', include('ckeditor_uploader.urls')),
]
INSTALLED_APPS = [
'ckeditor',
'ckeditor_uploader',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'prosvet_logs',
]
CKEDITOR_UPLOAD_PATH = 'uploads/'
CKEDITOR_CONFIGS = {
'default': {
'toolbar': 'None'
},
}
python
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question