我稱典範「客戶」在谷歌應用程序引擎的Python:在谷歌應用程序引擎,如何檢查模型是否爲空?
class Customer(db.Model):
name = db.StringProperty()
age = db.IntegerProperty()
之前,我創建Customer模型的任何實例/對象,我想檢查模式是空的(沒有物體創建了),我嘗試在Python這樣的:
customers = Customer.all()
for customer in customers:
if customer:
logging.info("there is customer in Customer Model!")
else:
logging.info("The Customer Model is empty!")
........
當有客戶模型沒有實例/對象,「客戶」,在上面的代碼是不是「無」,而行「爲客戶的客戶: 「總是跳出來(意味着」客戶「中什麼都沒有?),有什麼想法?另外,我可以在Django模板中檢查這個嗎? 預先感謝您。
請界定 「空」 模型 – 2012-04-04 12:06:33