管理文本面板忽略 html 个标签和段落

Admin text panel ignores html tags and paragraphs

出于某种原因,管理面板中的内容栏对任何 html 标签和新段落没有反应。

Here is example of my text in admin panel

This is how it displayed in page

我在 models.py 中的代码:

# coding: utf-8
from django.db import models

class Post(models.Model):
    title = models.CharField(max_length=255) 
    datetime = models.DateTimeField() 
    content = models.TextField(max_length=10000) 

def __unicode__(self):
    return self.title

def get_absolute_url(self):
    return '/blog/%i/' % self.id

views.py

from django.shortcuts import render
from blog.models import Post
from django.views.generic import ListView, DetailView
from registration.views import RegistrationView
from django.contrib.auth import logout

# Create your views here.

class PostsListView(ListView):
    model = Post                    

class PostDetailView(DetailView):   
    model = Post

def logout_view(request):
    logout(request)

默认情况下,管理面板不允许这样做。您将需要一个自定义编辑器来执行此操作。 This 可能会对您有所帮助。如果你不想安装不同的应用程序,你可以用

包装你的内容

<p>Some Text</p><p>Some Text</p>

然后使用

{% autoescape off %}{{your.content}}{% endautoescape %}

显示原始 HTML 内容。

例如

{% autoescape off %}
    <p>Some text </p><p>Some text </p>
{% endautoescape  %}