django summernote没有显示

问题描述 投票:0回答:2

views.朋友

def post_detail(request):
    if request.method == "POST":
        form = PostForm(request.POST)
        if form.is_valid():
            post = form.save(commit=False)
            post.user = request.user
            post.save()
            return redirect('post_detail')
    else:
        form = PostForm()
        return render(request, 'post_detail.html', {'form': form})

forms.朋友

class PostForm(forms.ModelForm):
    class Meta:
        model = Post
        fields = ('Penname','text',)
        widgets = {
            'text': SummernoteInplaceWidget(),
        }

models.朋友

class Post(models.Model):
    #user = models.OneToOneField(User)
    Penname = models.CharField(max_length=200)
    text = models.TextField()


    def __str__(self):
        return self.Penname

post_detail.html

<!DOCTYPE HTML>
<html>
<head>
  </head>
<body>
<div class="container">
    <form method="post">
      {{ form.as_p }}
      <button type="button" class="btn btn-primary">Submit</button>
    </form>
  <div>
    <h1>{{  post.Penname    }}</h1>
                                <p>{{   post.text|linebreaksbr  }}</p>
  </div>
</div>
</body>
</html>

URLs.朋友

urlpatterns = [
    url(r'^admin/', admin.site.urls),
    url(r'^summernote/', include('django_summernote.urls')),
    url(r'^post/$', imagec_views.post_detail, name='post_detail')
]

我想为我的文本字段选择一个summernote编辑器选项,但它只显示'Text'字符串并且summernote没有显示,即使它没有显示简单的文本字段

python html django
2个回答
0
投票

你是否将这些行添加到你的html文件中?

<!-- include summernote css/js-->
<link href="http://cdnjs.cloudflare.com/ajax/libs/summernote/0.8.3/summernote.css" rel="stylesheet">
<script src="http://cdnjs.cloudflare.com/ajax/libs/summernote/0.8.3/summernote.js"></script>


$('#text').summernote();

0
投票

检查浏览器中是否启用了JavaScript。

© www.soinside.com 2019 - 2024. All rights reserved.