本文整理汇总了Python中models.Feed.creat_time方法的典型用法代码示例。如果您正苦于以下问题:Python Feed.creat_time方法的具体用法?Python Feed.creat_time怎么用?Python Feed.creat_time使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Feed
的用法示例。
在下文中一共展示了Feed.creat_time方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: index
# 需要导入模块: from models import Feed [as 别名]
# 或者: from models.Feed import creat_time [as 别名]
def index(request):
if request.session.session_key:
current_user = request.user
if current_user.is_authenticated():
if request.method == 'POST':
form = NewFeedForm(request.POST)
if form.is_valid():
content = form.cleaned_data['content']
feed = Feed(content=content)
feed.creat_time = datetime.datetime.now()
current_user.update(push__feeds=feed)
return HttpResponseRedirect('/')
else:
form = NewFeedForm()
return render_to_response('accounts/broadcast.html', {'form':form, 'current_user':current_user, 'STATIC_URL':STATIC_URL}, context_instance=RequestContext(request))
# 这里应该还有个else,来处理有sessiondata但是已经注销了的情况
else:
if request.method == 'POST':
if 'login' in request.POST:
return indexlogin(request)
elif 'signup' in request.POST:
return indexsignup(request)
else:
form_login = AccountsLoginForm()
form_signup = AccountsSignupForm()
return render_to_response('index.html', {'form_login': form_login, 'form_signup':form_signup, 'STATIC_URL':STATIC_URL}, context_instance=RequestContext(request))
else:
if request.method == 'POST':
if 'login' in request.POST:
return indexlogin(request)
elif 'signup' in request.POST:
print 'signup'
return indexsignup(request)
else:
form_login = AccountsLoginForm()
form_signup = AccountsSignupForm()
return render_to_response('index.html', {'form_login': form_login, 'form_signup':form_signup, 'STATIC_URL':STATIC_URL}, context_instance=RequestContext(request))