Pythonを使用したGoogleAppEngineに「Customer」というモデルがあります。
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!")
........
Customerモデルにインスタンス/オブジェクトがない場合、上記のスニペットの「customers」は「None」ではありませんが、「for customer incustomers:」という行は常に飛び出します(「customers」には何もないことを意味しますか?)。 ?さらに、これをDjangoテンプレートで確認できますか?前もって感謝します。