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


Python Blog.title方法代码示例

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


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

示例1: new

# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import title [as 别名]
def new(request):
    blog = Blog()
    blog.title = 'This is a brand new blog.'
    blog.content = 'lalalallalalalalala'
    blog.created_at = datetime.datetime.now()

    blog.save()
    
    return HttpResponse('Save OK. <a href="/blog/view/%s/">view</a>'%blog.id)
开发者ID:blueidoo,项目名称:Tee,代码行数:11,代码来源:views.py

示例2: add_entry

# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import title [as 别名]
def add_entry():
    if not session.get('logged_in'):
        abort(401)
    blog = Blog()
    blog.title = cgi.escape(request.form['title'])
    blog.text = cgi.escape(request.form['text'])
    blog.put()
    flash('New entry was successfully posted')
    return redirect(url_for('show_entries'))
开发者ID:miquelet,项目名称:flask_projects,代码行数:11,代码来源:app.py

示例3: post

# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import title [as 别名]
def post(request):
    if (request.method=='POST'):
        data=JSONParser().parse(request)
        blog =  Blog()
        if(data['title'] and data['blogpost']):
            blog.title = data['title']
            blog.user = request.user
            blog.blogpost = data['blogpost']
            blog.save()
        return HttpResponseRedirect('/blog/userhome/',status=status.HTTP_200_OK)
开发者ID:vaishnavimerugu,项目名称:BlogIt,代码行数:12,代码来源:views.py

示例4: test_single_existence

# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import title [as 别名]
 def test_single_existence(self):
     """Test that the blog is created only once """
     self.blog = Blog(title="test", tag_line="new blog", entries_per_page=10,
                     recents=5, recent_comments=5)
     self.blog.save()
     blog = Blog(title="test", tag_line="new blog", entries_per_page=10,
                 recents=5, recent_comments=5)
     #should raise Exception when another blog is created
     self.assertRaises(Exception, blog.save)
     blog = Blog.objects.get()
     blog.title = 'edited'
     blog.save()
     self.assertEqual(Blog.objects.count(), 1)
     self.assertEqual(Blog.objects.get().title, 'edited')
开发者ID:huan80s,项目名称:django-blogango,代码行数:16,代码来源:tests.py

示例5: add_blog

# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import title [as 别名]
def add_blog(request, blog_id=None):
    init_session_data(request)
    blog = Blog()
    if blog_id:
        blog.id = blog_id
    blog.title = 'New Blog'
    blog.content_body = ''
    blog.time = datetime.now()
    blog.save()
    request.session['articles_created'] = request.session['articles_created'].append(blog.id)
    request.session['edited_version'] = str(blog.version)
    request.session['blog_modified'] = str(blog.id)
    request.session['modification'] = 'add'

    return HttpResponseRedirect('/editblog/' + str(blog.id))
开发者ID:kiStephane,项目名称:MyBlog_Assignment,代码行数:17,代码来源:views.py

示例6: save

# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import title [as 别名]
 def save(self, request):
     if not self.is_valid():
         return None
     blogid = self.cleaned_data["blogid"]
     title = self.cleaned_data["title"]
     markdown = self.cleaned_data["markdown"]
     
     if blogid:
         blog = Blog.objects.get(id=int(blogid))
     else:
         blog = Blog()
     blog.title = title
     blog.markdown = markdown
     blog.user = request.user
     blog = blog.save()
     return blog
开发者ID:yaongli,项目名称:yblog,代码行数:18,代码来源:forms.py

示例7: create

# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import title [as 别名]
def create(request):
    if not admin():
        return HttpResponseRedirect(users.create_login_url("/blogs"))
    form = BlogForm(request.POST)
    form.fields["category"].choices = [("", "请选择")] + [(category.key(), category.name) for category in Category.all()]
    if form.is_valid():
        blog = Blog()
        blog.title = form.cleaned_data["title"]
        blog.content = form.cleaned_data["content"]
        if form.cleaned_data["category"]:
            blog.category = Category.get(form.cleaned_data["category"])
        elif form.cleaned_data["user_tag"]:
            blog.category = Category.get_or_insert(form.cleaned_data["user_tag"], name=form.cleaned_data["user_tag"])
        blog.create()
        return HttpResponseRedirect("/blogs")
    else:
        return new(request)
开发者ID:proming,项目名称:myblogongae,代码行数:19,代码来源:views.py

示例8: create

# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import title [as 别名]
def create(request):
    if not admin():
        return HttpResponseRedirect(users.create_login_url('/blogs'))
    form = BlogForm(request.POST)
    form.fields['category'].choices = [('', '请选择')] + [(category.key(), category.name) for category in Category.all()]
    if form.is_valid():
        blog = Blog()
        blog.title = form.cleaned_data['title']
        blog.content = form.cleaned_data['content']
        if form.cleaned_data['category']:
            blog.category = Category.get(form.cleaned_data['category'])
        elif form.cleaned_data['user_tag']:
            blog.category = Category.get_or_insert(form.cleaned_data['user_tag'], name=form.cleaned_data['user_tag'])
        blog.create()
        return HttpResponseRedirect('/blogs')
    else:
        return new(request)
开发者ID:qubic,项目名称:myblogongae,代码行数:19,代码来源:views.py

示例9: save_blog

# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import title [as 别名]
def save_blog(request):
    bid = request.POST.get("bid", "").strip()
    title = request.POST.get("title", "").strip()
    category = request.POST.get("category", "").strip()
    content = request.POST.get("content", "").strip()

    if len(title) < 3 or len(content) < 4:
        return HttpResponseRedirect("/")

    if bid:
        try:
            bid = int(bid)
            # print 'bid: ', bid
        except:
            # print 'error bid: ', bid
            return HttpResponseRedirect("/")
        blog_set = Blog.objects.filter(id=bid)
        if blog_set:
            blog = blog_set[0]
        else:
            return HttpResponseRedirect("/")
    else:
        blog = Blog()
    blog.tags = "blog"
    blog.title = title
    blog.content = content
    blog.save()

    list_category = category.lower().split(",")
    for c in list_category:
        c = c.strip()
        if not c:
            continue
        cate_set = Category.objects.filter(name=c)
        if cate_set:
            # print 'category exist: ', c
            blog.categorys.add(cate_set[0])
        else:
            # print 'new category: ', c
            _category = Category(name=c)
            _category.save()

            blog.categorys.add(_category)

    return HttpResponseRedirect("/blog/%d.html" % blog.id)
开发者ID:xeon2007,项目名称:mycode,代码行数:47,代码来源:views.py

示例10: create_blog

# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import title [as 别名]
def create_blog (request):
    if request.POST:
        print request.POST
        blog = Blog()
        blog.user = request.user
        blog.title = request.POST.get('title')
        blog.description = request.POST.get('description')
##<<<<<<< HEAD
##        blog.tags = request.POST.get('blog_tags')
##=======
##        blog.tags = request.POST.get('tags')
##>>>>>>> 3eb972486d29895357819facd4a4c89bdc1b241f
        blog.save()
        return redirect_to (request, '/')
    else:
        from forms import BlogForm
        form = BlogForm
        return render(request, 'blog/blog.html', {'form':form})
开发者ID:pysecl1,项目名称:pyblog1,代码行数:20,代码来源:views.py

示例11: save_blog

# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import title [as 别名]
def save_blog(request):
    bid     = request.POST.get('bid', '').strip()
    title   = request.POST.get('title', '').strip()
    category= request.POST.get('category', '').strip()
    content = request.POST.get('content', '').strip()
    print request.POST
    if len(title) < 3 or len(content) < 4:
        print content
        print "title or content not correct"
        return HttpResponseRedirect('/')
    
    if bid:
        try:
            bid = int(bid)
        except:
            return HttpResponseRedirect('/')
        blog_set = Blog.objects.filter(id=bid)
        if blog_set:
            blog = blog_set[0]
        else:
            return HttpResponseRedirect('/')
    else:
        blog = Blog()
    blog.tags = 'blog'
    blog.title = title
    blog.content = content
    blog.save()

    list_category = category.lower().split(',')
    blog.categorys.clear()
    for c in list_category:
        c = c.strip()
        if not c:
            continue
        cate_set = Category.objects.filter(name=c)
        if cate_set:
            blog.categorys.add(cate_set[0])
        else:
            _category = Category(name=c)
            _category.save()
            
            blog.categorys.add(_category)

    return HttpResponseRedirect('/blog/%d.html'%blog.id)
开发者ID:lvshuchengyin,项目名称:mycode,代码行数:46,代码来源:views.py


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