我在django(v1.10.5)和python上制作了一个在线影院预订应用程序。自动创建选项列表
models.py:
TheaterLocation = [
(1, 'Naharlagun'),
]
FloorLevel = [
(1, 'Ground Floor'),
(2, 'Balcony'),
]
Row = [
]
Column = [
]
class Seat(models.Model):
theater_location = models.PositiveIntegerField(choices=TheaterLocation)
floor_level = models.PositiveIntegerField(choices=FloorLevel)
row_id = models.PositiveIntegerField()
column_id = models.PositiveIntegerField()
@property
def seat_id(self):
return "%s : %s : %s : %s" % (self.theater_location, self.floor_level, self.row_id, self.column_id)
我想要做的是,为自动创建一个选项列表和Column
这样的:
Row = [
(1, 'A'),
(2, 'B'),
...
...
(8, 'H'),
]
Column = [
1,2,3,4,5, ... , 22
]
我怎样才能做到像上述?
我很困惑。 “自动”是什么意思? – hashcode55
@ hashcode55我想使用shell或模板中的函数创建行和列。 – Aamu