我刚开始在django。我有一个类与一个变量称为available = models.CharField(max_length=20)
和其他isActive = models.BooleanField(default=True)
。默认情况下,变量available获得的值“available”。我希望能够得到字“unavailable”在available
字段,如果isActive
是False
。谢谢
def availibility (request, id):
listingData = Listing.objects.get(pk=id)
if listingData.isActive == False:
listingData.available = "unavailable"
listingData.save() return
render(request, "auctions/watchlist.html")
1条答案
按热度按时间5ssjco0h1#