Django博客图片

Django博客图片,django,django-templates,blogs,Django,Django Templates,Blogs,我的数据库里有这个 第1段 第2段 第2段 我想在段落之间放一张图片 我试过这个 <img src="where/photo/is"> class Post(models.Model): STATUS_CHOICES = ( ('draft','Draft'), ('published', 'Published'), ) title = models.CharField(max_length=250) slug = models.SlugField(max_len

我的数据库里有这个

第1段

第2段

第2段

我想在段落之间放一张图片

我试过这个

<img src="where/photo/is">

class Post(models.Model):
STATUS_CHOICES = (
    ('draft','Draft'),
    ('published', 'Published'),
)

title = models.CharField(max_length=250)
slug = models.SlugField(max_length=250, unique_for_date ='publish')
author = models.ForeignKey(User, related_name='blog_posts')
body = models.TextField()
publish = models.DateTimeField(default=timezone.now)
created = models.DateTimeField(auto_now_add=True)
updated = models.DateTimeField(auto_now=True)
image = models.ImageField(upload_to='posts', default='path/to/my/default/image.jpg')
status = models.CharField(max_length=10, choices=STATUS_CHOICES,
    default='draft')
objects = models.Manager()
published = PublishedManager()
tags = TaggableManager()

class Meta:
    ordering = ('-publish',)

def __str__(self):
    return self.title

def get_absolute_url(self):
    return reverse('blog:post_detail',
            args=[self.slug])
在数据库中,我使用| safe过滤器,但它仍然打印与上面相同的内容


您知道如何执行该操作吗?

您好,如果您想使用图像创建长描述,意味着您可以使用django ckeditor,此软件包将为您提供RichTextField,以便您可以使用图像创建批量段落。

因此,我的意思是,我从数据库中获取文本,但我没有一张图片,我想从我的图片中添加。您看到问题了吗?请分享您迄今为止尝试过的代码
current_site = get_current_site(request)
namesite = current_site.name
domain = current_site.domain

post = Post.published.get(slug=post)

profile = Profile.objects.get(id=1)


if request.method == 'POST':
    comment_form = CommentForm(data=request.POST)
    if comment_form.is_valid():
        #create Comment object but do not say to database just yet
        new_comment = comment_form.save(commit=False)
        #Assigng the current post to the comment
        new_comment.post = post
        #save the comment to the database
        new_comment.save()
        comment_form = CommentForm()
else:
    comment_form = CommentForm()

return render(request, 'blog/detail.html',
                {'post': post, 'comments': comments, 
                 'comment_form': comment_form, 'namesite': namesite, 'domain': domain, 'profile': profile })