本文整理汇总了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})
示例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)
示例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")
示例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)