我想知道我如何能够使用外键来执行搜索
class Product(models.Model):
name = models.CharField(max_length = 127)
description = models.TextField()
code = models.CharField(max_length = 127)
def __unicode__(self):
return self.name + " - " + self.code
class ProductLot(models.Model):
product = models.ForeignKey(Product)
code = models.CharField(max_length = 30)
lot_no = models.CharField(max_length = 30)
location = models.CharField(max_length = 127)
incoming = models.IntegerField()
commited = models.IntegerField()
available = models.IntegerField()
reorder = models.IntegerField()
created_date = models.DateField(auto_now_add=True)
def __unicode__(self):
return self.code + " - " + self.product.name + " - " + self.lot_no
class LotComment(models.Model):
product_lot …
Run Code Online (Sandbox Code Playgroud) 我需要在我的代码中提供一些密码,API密钥和类似的敏感数据.这方面的最佳做法是什么?硬编码?SQlite的?一些加密框架?
如果我有以下课程:
class theater:
def __init__(self):
self.__seatMatrix=[10]*5
self.__seats=seating[0]
self.__rows=len(seating)
Run Code Online (Sandbox Code Playgroud)
如何实现get/setter来更新席位值?座位= [10]*5,5行,10个座位.在整个周末,我一直在转过头.当我尝试:
def getseats(self):
self.__seats
Run Code Online (Sandbox Code Playgroud)
它没有返回任何东西.
/安迪