当前位置: 首页>>代码示例>>Python>>正文


Python Post.author_id方法代码示例

本文整理汇总了Python中models.Post.author_id方法的典型用法代码示例。如果您正苦于以下问题:Python Post.author_id方法的具体用法?Python Post.author_id怎么用?Python Post.author_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.Post的用法示例。


在下文中一共展示了Post.author_id方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: add_post

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import author_id [as 别名]
def add_post():
        form = NewPostForm()
        if form.validate_on_submit():
                post = Post()
                form.populate_obj(post)
                post.author_id = current_user.id
                db.session.add(post)
                db.session.commit()
                return redirect('/')
        return render_template("add_post.html", form = form)
开发者ID:AngieBrilliance,项目名称:flask_evolution,代码行数:12,代码来源:views.py

示例2: add_post

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import author_id [as 别名]
def add_post():
    form = PostForm(request.form)
    if request.method == 'POST' and form.validate():
        post = Post()
        form.populate_obj(post)
        post.author_id = g.user.id
        post.timestamp = datetime.utcnow()
        db.session.add(post)
        db.session.commit()
        return redirect(url_for('show_post', post_id=post.id))
    return render_template('content_add_post.html',
                           title='Add post',
                           form=form,
                           user=g.user)
开发者ID:YoYuUm,项目名称:Blonkey,代码行数:16,代码来源:views.py

示例3: create_post

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import author_id [as 别名]
def create_post():
    if request.method == 'GET':
        if 'username' not in session:
            return redirect('/login')
        return render_template('newpost.html')
    else:
        title = request.form['title']
        text = request.form['text']
        post = Post(title, text)
        user = current_user()
        post.author_id = user.id
        db.session.add(post)
        db.session.commit()
        return redirect('/post/' + str(post.id))
开发者ID:adicu,项目名称:intro-webapps,代码行数:16,代码来源:routes.py

示例4: save

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import author_id [as 别名]
 def save(cls, request: Request, *args, **kwargs):
     """ Метод для сохранения поста
     :param request:
     :param kwargs:
     :return:
     """
     if request.get("id", False):
         post = blog.get_post(request.get("id"))
     else:
         post = Post()
     post.title = request.get("title")
     post.short = request.get("short")
     post.imgs = request.get("imgs", [])
     post.body = request.get("body", "")
     post.tags = request.get("tags", [])
     post.category = request.get("category", None)
     post.draft = request.get("draft", True)
     post.author_id = request.get("author_id", False)
     post.author_name = request.get("author_name", False)
     post.source = request.get("source", False)
     return {"post_id": post.save()}
开发者ID:ayurjev,项目名称:z9blog-api,代码行数:23,代码来源:controllers.py


注:本文中的models.Post.author_id方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。