當前位置: 首頁>>代碼示例>>Python>>正文


Python Activity.date方法代碼示例

本文整理匯總了Python中bootcamp.activities.models.Activity.date方法的典型用法代碼示例。如果您正苦於以下問題:Python Activity.date方法的具體用法?Python Activity.date怎麽用?Python Activity.date使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在bootcamp.activities.models.Activity的用法示例。


在下文中一共展示了Activity.date方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: setUp

# 需要導入模塊: from bootcamp.activities.models import Activity [as 別名]
# 或者: from bootcamp.activities.models.Activity import date [as 別名]
 def setUp(self):
     # creates a fictif user
     u = User()
     u.username = "testusername"
     u.password = "secretpassword"
     u.save()
     
     # create an activity related to that user
     activity = Activity()
     activity.user = u
     activity.activity_type = "Favorite"
     activity.date = timezone.now()
     
     # check we can save it to the database
     activity.save()
     
     # creates two fictif users
     u1 = User()
     u1.username = "testusername1"
     u1.password = "secretpassword1"
     u1.save()
     u2 = User()
     u2.username = "testusername2"
     u2.password = "secretpassword2"
     u2.save()
     
     # create one notification for each type of notification
     # Liked
     notifL = Notification()
     notifL.from_user = u1
     notifL.to_user = u2
     notifL.date = timezone.now()
     notifL.notification_type = 'Liked' # this is a like
     # save it to the database
     notifL.save()
     # Commented
     notifC = Notification()
     notifC.from_user = u1
     notifC.to_user = u2
     notifC.date = timezone.now()
     notifC.notification_type = 'Commented'
     # save it to the database
     notifC.save()
     # Favorited
     notifF = Notification()
     notifF.from_user = u1
     notifF.to_user = u2
     notifF.date = timezone.now()
     notifF.notification_type = 'Favorited'
     # save it to the database
     notifF.save()
     # Answered
     notifA = Notification()
     notifA.from_user = u1
     notifA.to_user = u2
     notifA.date = timezone.now()
     notifA.notification_type = 'Answered'
     # save it to the database
     notifA.save()
     # Accepted answer
     notifW = Notification()
     notifW.from_user = u1
     notifW.to_user = u2
     notifW.date = timezone.now()
     notifW.notification_type = 'Accepted Answer'
     # save it to the database
     notifW.save()
     # Edited article
     notifE = Notification()
     notifE.from_user = u1
     notifE.to_user = u2
     notifE.date = timezone.now()
     notifE.notification_type = 'Edited Article'
     # save it to the database
     notifE.save()
     # Also commented
     notifS = Notification()
     notifS.from_user = u1
     notifS.to_user = u2
     notifS.date = timezone.now()
     notifS.notification_type = 'Also Commented'
     # save it to the database
     notifS.save()
開發者ID:gvrossom,項目名稱:bootcamp,代碼行數:85,代碼來源:tests.py


注:本文中的bootcamp.activities.models.Activity.date方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。