本文整理汇总了Python中comments.models.Comment.content方法的典型用法代码示例。如果您正苦于以下问题:Python Comment.content方法的具体用法?Python Comment.content怎么用?Python Comment.content使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类comments.models.Comment
的用法示例。
在下文中一共展示了Comment.content方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add
# 需要导入模块: from comments.models import Comment [as 别名]
# 或者: from comments.models.Comment import content [as 别名]
def add(request):
print "Hit add request for comment"
r = '/'
if request.method =='POST':
form = CommentForm(request.POST)
#print repr(form.cleaned_data)
#print request.POST
if form.is_valid():
d = form.cleaned_data
#print d['suid']
if suid_store.check(d['suid']):
suid_store.add(d['suid'])
suid_store.trim()
c = Comment()
p = d['parent'].split(':')
pt = Ticket
r = '/tickets/'
print p[0]
if p[0] in ('ticket','Ticket'):
pt = Ticket
r = '/tickets/'
elif p[0] in ('comment','com','Comment','comments','Comments'):
pt = Comment
r = '/comments/'
#print r
#Insert other comment parents here
try:
p = pt.objects.get(id=int(p[1]))
#print "Got model of type " + str(type(pt))
r += str(p.id) + '/'
except:
#print 'Cannot get model of type ' + str(type(pt))
return HttpResponse('Invalid Parent')
#c.content_type = ContentType.objects.get_for_model(pt)
c.parent = p
c.submittedby = request.user.member
c.submittedtime = datetime.datetime.now()
c.content = d['content']
c.save()
#print d['files']
fs = getfilesfromfields(d['files'],d['autofiles'])
if fs:
print fs
c.attachedfiles.add(*fs)
c.save()
#print "Id for new comment", c.id
#print r
else:
print "Suid seen before"
else:
print "Form is invalid"
#print r
return HttpResponseRedirect(r)