zoukankan      html  css  js  c++  java
  • BBS第四天

    1富文本编辑框的使用

    <script src="/static/kindeditor/kindeditor-all.js"></script>
    <script>
    KindEditor.ready(function (K) {
    window.editor = K.create('#content', {   #文本域的id
    '100%',
    height: '400px',
    resizeType: 0,                            #格式禁止拖拽等
    uploadJson: '/add_image/',       #上传图片请求
    extraFileUploadParams: {
    csrfmiddlewaretoken: '{{ csrf_token }}'    #可以携带参数
    }
    });
    });
    </script>

    2.个人站点urls

    url(r'^(?P<site>w+)/(?P<group>category|tag|archive)/(?P<key>.+)$', views.site),   #返回分组信息

    url(r'^(?P<site>w+)$', views.site),   #通过url直接访问
    url(r'^(?P<site>w+)/$', views.site)

    3.登录装饰器导入

    from django.contrib.auth.decorators import login_required,

    4.导入相关模块

    from django.db.models import Count
    from django.db.models.functions import TruncMonth

    # 添加文章正文图片
    def add_image(request):
    print(request.FILES)

    path = 'media/img'
    if not os.path.exists(path):
    os.mkdir(path)

    file = request.FILES.get('imgFile', None)

    img_path = path + "/" + file.name
    with open(img_path, 'wb') as f:
    for line in file:
    f.write(line)

    return JsonResponse({
    "error": 0,
    'url': '/' + img_path
    })

    soup = BeautifulSoup(content, 'html.parser')
    desc = soup.text.strip()[0:100] # 解析后数据存放在soup.text

    def site(request, site, group=None, key=None):

    from bs4 import BeautifulSoup

  • 相关阅读:
    图解设计模式-Visitor模式
    图解设计模式-Decorator模式
    图解设计模式-Strategy模式
    图解设计模式-Bridge模式
    HashMap源码
    LinkedList源码
    Vector源码
    ArrayList源码
    图解设计模式-Abstract Factory模式
    图解设计模式-Builder模式
  • 原文地址:https://www.cnblogs.com/suncunxu/p/10560120.html
Copyright © 2011-2022 走看看