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


Python Post.objects方法代码示例

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


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

示例1: tags

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import objects [as 别名]
def tags(tag=None):
    if tag is None:
        tags = Post.objects(visible=True).distinct('tags')
        return render_template('posts/tags.html',
            tags=tags)
    else:
        posts = Post.objects(tags=tag, visible=POST_VISIBLE)
        return render_template('posts/tag_list.html',
            posts=posts,
            tag=tag,
            title=tag)
开发者ID:ardinor,项目名称:mojibake-gae,代码行数:13,代码来源:views.py

示例2: admin_list

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import objects [as 别名]
def admin_list(group):
  user = User.objects(id=current_user.id).get()
  if group not in user.moderating:
    abort(404)

  unapproved_posts = Post.objects(archived=False, approved=False, group=group)
  approved_posts = Post.objects(archived=False, approved=True, group=group)

  return render_template('admin/list.html',
    group=group,
    unapproved_posts=unapproved_posts,
    approved_posts=approved_posts)
开发者ID:srir,项目名称:confessionsplus,代码行数:14,代码来源:views.py

示例3: update

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import objects [as 别名]
def update(request):
    id = eval("request." + request.method + "['id']")
    if Post.objects(id=id):
        post = Post.objects(id=id)[0]
        if request.method == 'POST':
            template = 'admin/index.html'
            # update field values and save to mongo
            post.title = request.POST['title']
            #str_date_published = request.POST['date_published']
            #post.date_published = datetime.fromtimestamp(mktime(time.strptime(str_date_published, "%b %d %Y")))
            post.publisher = request.POST['publisher']
            post.papertype = request.POST['papertype']
            post.authors = request.POST['authors']
            #post.additional_info = request.POST['additional_info']
            #post.page_num = request.POST['page_num']
            #if request.POST.get('selectedpublication', True):
            #    post.selectedpublication = True;
            post.save()
            params = {'Posts': Post.objects} 

        elif request.method == 'GET':
            template = 'admin/update.html'
            params = {'post':post}
    
    elif Section.objects(id=id):
        section = Section.objects(id=id)[0]
        if request.method == 'POST':
            template = 'admin/index.html'
            # update field values and save to mongo
            section.heading = request.POST['heading']
            section.content = request.POST['content']
            section.save()
            params = {'Sections': Section.objects} 

        elif request.method == 'GET':
            template = 'admin/update.html'
            params = {'section':section}
            
    elif Profile.objects(id=id):
        profile = Profile.objects(id=id)[0]
        if request.method == 'POST':
            template = 'admin/index.html'
            # update field values and save to mongo
            profile.details = request.POST['profile']
            profile.save()
            params = {'Profile': Profile.objects.limit(1)} 

        elif request.method == 'GET':
            template = 'admin/update.html'
            params = {'Profile': Profile.objects.limit(1)}

    return render_to_response(template, params, context_instance=RequestContext(request))
开发者ID:micadeyeye,项目名称:Blongo,代码行数:54,代码来源:views.py

示例4: get_post

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import objects [as 别名]
def get_post(ID):
    parsed = parse_id(ID)
    if parsed:
        year, month, day, s = parse_id(ID)
        d = date(year, month, day)
        posts = Post.objects(date=d, slug=s)
        return posts.first()
开发者ID:mahmoudhossam,项目名称:blog,代码行数:9,代码来源:util.py

示例5: update

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import objects [as 别名]
def update(request):
    id = eval("request." + request.method + "['id']")
#    if 'id' in request.POST:
#        if request.method == 'POST':
#	    id = request.POST['id'];
#        elif request.method == 'GET':
#            id = request.GET["id"]
#    else:
#        id = 0 
    post = Post.objects(id=id)[0]
    
    if request.method == 'POST':
        # update field values and save to mongo
        post.title = request.POST['title']
        post.last_update = datetime.datetime.now() 
        post.content = request.POST['content']
        post.save()
        template = 'index.html'
        params = {'Posts': Post.objects} 

    elif request.method == 'GET':
        template = 'update.html'
        params = {'post':post}
   
    return render_to_response(template, params, context_instance=RequestContext(request))
开发者ID:lindylin1817,项目名称:test_mongodb_python,代码行数:27,代码来源:views.py

示例6: geo_list

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import objects [as 别名]
def geo_list():
    form = GeoForm()
    posts_found = []
    for post in Post.objects():
        if within_ran(post, form.lat.data, form.lon.data):
            posts_found.append(post)
    return render_template("geo.html", title = "geo", posts = posts_found, form = form)
开发者ID:rzlee,项目名称:moments-backend,代码行数:9,代码来源:views.py

示例7: tags

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import objects [as 别名]
def tags(tag):
    page = request.args.get("page", 1)

    paginated_posts = Post.objects(tags=tag).paginate(page=int(page), per_page=6)
    tags = Post.objects.item_frequencies("tags")

    return render_template("normal_list.html", pagination=paginated_posts, tags=tags, tag=tag)
开发者ID:xiaofeiyang,项目名称:openshift-flask-mongdb,代码行数:9,代码来源:views.py

示例8: tag_image

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import objects [as 别名]
def tag_image():
	if request.method == 'POST':
		slugval = str(request.form['slug'])
		tagval = str(request.form['tag'])
		print slugval
		p = Post.objects(slug = slugval)
		print len(p)
		if len(p) >= 1:
			#otherwise somethings wrong
			post = p[0]
			post.tags.append(tagval)
			post.save()
		tag_url = '/tagged/' + tagval
		return redirect(tag_url)
	posts_found = Post.objects()
	return render_template('tag.html', posts = posts_found)
开发者ID:rzlee,项目名称:moments-backend,代码行数:18,代码来源:views.py

示例9: get

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import objects [as 别名]
    def get(self, post_url=None):
        """ View for a single post
        """
        today = date.today().strftime('%d-%b-%Y')
        is_today = True if post_url == today else False

        if 'today' in request.path:
            return redirect(url_for('.post', post_url=today))

        post = Post.objects(user_ref=current_user.id, url=post_url).first()

        if post is None:
            try:
                validated_date = validate_date(post_url).strftime('%d-%b-%Y')
            except:
                flash('No post found')
                return redirect(url_for('.post', post_url=today))

            if validated_date != post_url:
                return redirect(url_for('.post', post_url=validated_date))

            if is_today:
                # create a new post for today
                post = DailyPost(user_ref=current_user.id, url=today, kind='Daily')
                post.save()
            else:
                flash('No post found')
                return redirect(url_for('.post', post_url=today))

        return render_template('writer/write.html', post=post, is_today=is_today)
开发者ID:joehand,项目名称:handAPI,代码行数:32,代码来源:views.py

示例10: show_posts

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import objects [as 别名]
def show_posts(user_name):
    try:
        user_obj = User.objects.get(username=user_name)
        user_posts = Post.objects(user_id=user_obj).order_by('-created_on')[:3]
        print user_obj.blog_title
        return render_template('show_posts.html', posts=user_posts)

    except(DoesNotExist):
        return abort(404)
开发者ID:c0debrain,项目名称:Simple-blog-with-flask,代码行数:11,代码来源:views.py

示例11: example_query

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import objects [as 别名]
def example_query():
    for post in Post.objects:
        print post.title
        print "=" * len(post.title)

        if isinstance(post, TextPost):
            print post.content

        if isinstance(post, LinkPost):
            print "Link:", post.link_url

        print

        for post in Post.objects(tags='mongodb'):
            print post.title

        num_posts = Post.objects(tags="mongodb").count()
        print "Found %d posts with tag 'mongodb'" % num_posts
开发者ID:jwmatthews,项目名称:splice-server,代码行数:20,代码来源:main.py

示例12: category

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import objects [as 别名]
def category(slug):
    """ Category page controller """
    category = Category.objects().filter_by(slug=slug).first()
    if not post:
        abort(404)
    paginator = paginate(request, Post.objects().filter_by(is_published=True, 
                                                           category_id=category.id))

    return {'category': category, 'paginator': paginator}
开发者ID:kvex,项目名称:foobar,代码行数:11,代码来源:foobar.py

示例13: deny

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import objects [as 别名]
def deny(group, slug):
  user = User.objects(id=current_user.id).get()
  if group not in user.moderating:
    abort(404)

  post = Post.objects(group=group, slug=slug).get_or_404()
  post.archived = True
  post.save()

  return redirect(url_for('admin.admin_list', group=group))
开发者ID:srir,项目名称:confessionsplus,代码行数:12,代码来源:views.py

示例14: put

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import objects [as 别名]
 def put(self, id):
     if 'content' in request.data:
         try:
             content = json.loads(request.data)['content']
             post = Post.objects(id=id).first()
             post.content = content
             post.save()
             return jsonify( post.to_dict() )
         except:
             abort(400)
     return abort(400)
开发者ID:joehand,项目名称:handAPI,代码行数:13,代码来源:views.py

示例15: retrieve

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import objects [as 别名]
def retrieve(request):
    id = eval("request." + request.method + "['_id']")
    post = Post.objects(id='_id')[0]
    
    if request.method == 'POST':
        return render_to_response(template, params, context_instance=RequestContext(post.first_name))
    elif request.method == 'GET':
        template = 'update.html'
        params = {'post':post}
   
    return render_to_response(template, params, context_instance=RequestContext(request))
开发者ID:Pranay1989,项目名称:App_Django,代码行数:13,代码来源:views.py


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