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


Python Comment.name方法代码示例

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


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

示例1: blog_comment

# 需要导入模块: from blog.models import Comment [as 别名]
# 或者: from blog.models.Comment import name [as 别名]
def blog_comment(request, offset):
	offset=int(offset)
	e=Entries.objects.filter(id=offset)
	if not request.POST['name']:
		return HttpResponse(u'이름을 입력하세요')
	cmt_name=request.POST['name']
	cmt_content=request.POST['content']
	if not request.POST['content']:
		return HttpResponse(u'글 내용을 입력하세요')
	cmt_password=request.POST['password']
	if not request.POST['password']:
		return HttpResponse(u'비밀번호를 입력하세요')
	cmt_password = md5.md5(cmt_password).hexdigest()
	cmt=Comment()
	try:
		cmt.name=cmt_name
		cmt.password=cmt_password
		cmt.text=cmt_content
		ie=Entries.objects.get(id=request.POST['entry_id'])
		cmt.entry=ie
		ie.cnumber=ie.cnumber+1
		ie.save()
		cmt.save()
	except:
		return HttpResponse('오류가 나고 있습니다')
	c=Comment.objects.filter(entry=Entries.objects.get(id=offset))
	return render_to_response('blog.html',{'offset':offset,'e':e,'c':c})
开发者ID:kimshangyup,项目名称:myfirstsns,代码行数:29,代码来源:views.py

示例2: test_creating_a_new_comment_and_saving_it_to_the_database

# 需要导入模块: from blog.models import Comment [as 别名]
# 或者: from blog.models.Comment import name [as 别名]
 def test_creating_a_new_comment_and_saving_it_to_the_database(self):
     # start by create one Category and one post
     category = Category()
     category.name = "First"
     category.slug = "first"
     category.save()
     
     # create new post
     post = Post()
     post.category = category
     post.title = "First post"
     post.content = "Content"
     post.visable = True
     post.save()
     
     # create one comment
     comment = Comment()
     comment.name = "John"
     comment.content = "This is cool"
     comment.post = post
     
     # check save
     comment.save()
     
     # now check we can find it in the database
     all_comment_in_database = Comment.objects.all()
     self.assertEquals(len(all_comment_in_database), 1)
     only_comment_in_database = all_comment_in_database[0]
     self.assertEquals(only_comment_in_database, comment)
     
     # and check that it's saved its two attributes: name and content
     self.assertEquals(only_comment_in_database.name, comment.name)
     self.assertEquals(only_comment_in_database.content, comment.content)
开发者ID:pabllo87,项目名称:Ultra-simple-blog,代码行数:35,代码来源:models.py

示例3: form

# 需要导入模块: from blog.models import Comment [as 别名]
# 或者: from blog.models.Comment import name [as 别名]
def form(request):
	if request.method=="POST":
		c=Comment()
		c.name=request.POST["name"]
		c.phone=request.POST["phone"]
		c.email=request.POST["email"]
		c.message=request.POST["message"]
		c.save()
		ht = "<html><body style = 'background-color: #2c3e50 ;color:white;font-size:64px ;text-align:center' >Thank you !!!  <a href='/'>Home</a></body></html>" 
    	return HttpResponse(ht)
	return HttpResponse("Error")
开发者ID:sanu11,项目名称:MySite,代码行数:13,代码来源:views.py

示例4: blog_show_comment

# 需要导入模块: from blog.models import Comment [as 别名]
# 或者: from blog.models.Comment import name [as 别名]
def blog_show_comment(request, blog_id):
    blog = Article.objects.get(pk=blog_id)
    if request.method == 'POST':
        name = request.POST['name']
        content = request.POST['content']
        print name, content
        try:
            new_comment = Comment()
            new_comment.article = blog
            new_comment.name = name
            new_comment.content = content
            new_comment.save()
            import datetime
            date = unicode(datetime.datetime.now())[0:-13]                     #TODO datatype优化
            date = u' ' + date
            content = unicode(escape(content))
            data_returned = {"name": name, "content": content, "date": date}
        except Exception, ex:
            print ex
            return HttpResponse("false")

        return JsonResponse(data_returned)
开发者ID:bricksfx,项目名称:django_self_blog,代码行数:24,代码来源:views.py


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