[英]Attach image to news in django admin when user has alternatives
I have Django model for storing news, shortly 我很快就有了用于存储新闻的Django模型
class News(models.Model):
text = models.CharField('content')
Editors may attach image to every peace of news applying one of 3 methods: 编辑可以使用以下三种方法之一将图像附加到新闻的每一个和平中:
The main question I wonder how to design database to store the image path and photo id simultaneously. 我想知道的主要问题是如何设计数据库以同时存储图像路径和照片ID。
Also how this should look like in django admin. 以及在django admin中的外观。 What I need to extend. 我需要扩展的内容。
I guess using a HTML editor for this type of project will be quite useful. 我猜对于这种类型的项目使用HTML编辑器将非常有用。 CKEditor or TinyMCE are pretty good WYSIWYG editors. CKEditor或TinyMCE是相当不错的WYSIWYG编辑器。 I have previously used CKEditor for few of my projects and it is amazing when it comes to edit content with images and formatting etc. django-ckeditor provides a simple integration of ckeditor with django. 我以前在少数几个项目中都使用过CKEditor ,当使用图像和格式编辑内容时,这真是太神奇了。django-ckeditor提供了ckeditor与django的简单集成。 All of the 3 methods that are required for your project, are easily achievable by this. 这样就可以轻松实现项目所需的所有3种方法。 Hope it helps. 希望能帮助到你。
Regarding database design: If you do decide to use ckeditor, you won't need any change in database design, as the data is stored as HTML within the database. 关于数据库设计:如果您决定使用ckeditor,则无需对数据库设计进行任何更改,因为数据以HTML格式存储在数据库中。 The image path is stored within the HTML so you will not have to worry about it 图片路径存储在HTML中,因此您不必担心它
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.