摘要: Django用户登录与注册系统 一、创建项目 1.1.创建项目和app django-admin startproject mysite_login python manage.py startapp login 1.2.设置时区和语言 Django默认使用美国时间和英语,在项目的settings文 阅读全文
posted @ 2018-11-26 17:41 王竹笙 阅读(3137) 评论(0) 推荐(0) 编辑
摘要: BBS论坛(三十三) 33.celery实现邮件异步发送 (1)task.py pip install celery redis from celery import Celery from flask import Flask from flask_mail import Message from 阅读全文
posted @ 2018-11-26 16:45 王竹笙 阅读(4) 评论(0) 推荐(0) 编辑
摘要: BBS论坛(二十九) 29.帖子详情页布局 (1)front/hooks.py @bp.errorhandler def page_not_found(): return render_template('front/front_404.html'),404 (2)front/front_404.h 阅读全文
posted @ 2018-11-26 16:39 王竹笙 阅读(187) 评论(0) 推荐(0) 编辑
摘要: BBS论坛(二十七) 27.首页帖子列表布局完成 (1)apps/models.py 把帖子跟用户关联起来 class PostModel(db.Model): __tablename__ = 'post' id = db.Column(db.Integer, primary_key=True, a 阅读全文
posted @ 2018-11-26 16:37 王竹笙 阅读(162) 评论(0) 推荐(0) 编辑
摘要: BBS论坛(二十六) 26.发布帖子前台代码逻辑完成 (1)front/hooks.py from .views import bp from flask import session,g from .models import FrontUser import config @bp.before_ 阅读全文
posted @ 2018-11-26 16:36 王竹笙 阅读(190) 评论(0) 推荐(0) 编辑
摘要: BBS论坛(二十五) 25.1.发布帖子后台逻辑完成 (1)apps/models.py class PostModel(db.Model): __tablename__ = 'post' id = db.Column(db.Integer, primary_key=True, autoincrem 阅读全文
posted @ 2018-11-26 16:34 王竹笙 阅读(408) 评论(0) 推荐(0) 编辑
摘要: BBS论坛(二十四) 24.1.编辑板块 cms/js/banners.js $(function () { $('.edit-board-btn').click(function () { var self = $(this); var tr = self.parent().parent(); v 阅读全文
posted @ 2018-11-26 16:33 王竹笙 阅读(310) 评论(0) 推荐(0) 编辑
摘要: BBS论坛(二十三) 23.添加板块 (1)apps/models class BoardModel(db.Model): __tablename__ = 'board' id = db.Column(db.Integer, primary_key=True, autoincrement=True) 阅读全文
posted @ 2018-11-26 16:32 王竹笙 阅读(232) 评论(0) 推荐(0) 编辑
摘要: BBS论坛(二十二) 22.1.七牛js上传轮播图图片 (1)common/zlqiniu.js 'use strict'; var zlqiniu = { 'setup': function (args) { var domain = args['domain']; var params = { 阅读全文
posted @ 2018-11-26 16:30 王竹笙 阅读(296) 评论(0) 推荐(0) 编辑
摘要: BBS论坛(二十一) 21.1.编辑轮播图功能完成 (1)cms_banners.html 把属性绑定到<tr>上面,方便找到各属性的值 <tbody> {% for banner in banners %} <tr data-name="{{ banner.name }}" data-id="{{ 阅读全文
posted @ 2018-11-26 16:28 王竹笙 阅读(196) 评论(0) 推荐(0) 编辑
摘要: BBS论坛(二十) 20.1.cms添加轮播图后台逻辑代码完成 (1)apps/models.py from exts import db from datetime import datetime class BannerModel(db.Model): __tablename__ = 'bann 阅读全文
posted @ 2018-11-26 16:26 王竹笙 阅读(156) 评论(0) 推荐(0) 编辑
摘要: BBS论坛(十八) 18.首页轮播图实现 (1)front/css/front_base.css .main-container{ width: 990px; margin: 0 auto; overflow: hidden; } .lg-container{ width: 730px; float 阅读全文
posted @ 2018-11-26 16:24 王竹笙 阅读(217) 评论(0) 推荐(0) 编辑
摘要: BBS论坛(十七) 17.首页导航条实现和代码抽离 (1)temlates/common/_head.html <meta name="csrf-token" content="{{ csrf_token() }}"> <script src="http://cdn.bootcss.com/jque 阅读全文
posted @ 2018-11-26 16:23 王竹笙 阅读(196) 评论(0) 推荐(0) 编辑
摘要: BBS论坛(十六) 16.登录功能完成 (1)front/forms.py class SigninForm(BaseForm): telephone = StringField(validators=[Regexp(r'1[3578]\d{9}', message='请输入正确格式的手机号码')] 阅读全文
posted @ 2018-11-26 16:21 王竹笙 阅读(200) 评论(0) 推荐(0) 编辑
摘要: BBS论坛(十五) 15.1.登录界面完成 (1)front/signbase.html {% from 'common/_macros.html' import static %} <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF 阅读全文
posted @ 2018-11-26 16:20 王竹笙 阅读(285) 评论(0) 推荐(0) 编辑
摘要: BBS论坛(十四) 14.1注册完成跳到上一个页面 (1)front/form.py # front/forms.py __author__ = 'derek' from ..forms import BaseForm from wtforms import StringField from wtf 阅读全文
posted @ 2018-11-26 16:19 王竹笙 阅读(162) 评论(0) 推荐(0) 编辑
摘要: BBS论坛(十三) 13.1点击更换图形验证码 (1)front/signup.html <div class="form-group"> <div class="input-group"> <input type="text" class="form-control" name="graph_ca 阅读全文
posted @ 2018-11-26 16:18 王竹笙 阅读(274) 评论(0) 推荐(0) 编辑
摘要: BBS论坛(十二) 12.1.图形验证码生成 (1)utils/captcha/init.py import random import string # Image:一个画布 # ImageDraw:一个画笔 # ImageFont:画笔的字体 from PIL import Image,Imag 阅读全文
posted @ 2018-11-26 16:16 王竹笙 阅读(202) 评论(0) 推荐(0) 编辑
摘要: BBS论坛(十) 10.1.客户端权限验证功能完成 (1)cms/cms_profile 显示当前用户的角色和权限 <tr> <td>角色:</td> <td> {% for role in user.roles %} {{ role.name }} {% if not loop.last %},{ 阅读全文
posted @ 2018-11-26 16:11 王竹笙 阅读(268) 评论(0) 推荐(0) 编辑
摘要: BBS论坛(九) 9.1.权限和角色模型定义 (1)cms/models class CMSPermission(object): ALL_PERMISSION = 0b11111111 # 1.访问者的权限 VISITOR = 0b00000001 # 2.管理帖子的权限 POSTER = 0b0 阅读全文
posted @ 2018-11-26 16:09 王竹笙 阅读(232) 评论(0) 推荐(0) 编辑