I am very new to django. I am trying to implement small application for my business which is a rental service for a football field which is made of artificial grass. Service is based on hourly rental of the field. People can rent the field hourly or they can chose membership option which includes specific day and hour in a week for a defined period. I have two classes in my model.
一项是一次性保留。 人民可以在一周内将足球场保留一天和小时。 这非常简单。
class Reservation(models.Model):
name = models.ForeignKey(User)
membership = models.ForeignKey((Member), blank=True, null=True, editable=False)
date = models.DateField()
field_name = models.ForeignKey(Field)
fee = models.DecimalField(decimal_places=0, max_digits=3)
is_member = models.BooleanField(default=False, editable=False)
is_active = models.BooleanField(default=True)
def __unicode__(self):
return u %s %s %s %s % (self.date, self.user.first_name,self.user.last_name, self.field)
class Meta:
unique_together = (("date", "field"))
另一位成员。 人民可以申请成为成员。 当有人申请船舶时,即在船舶起步和起步之间,要自动设定对该日及时间段的保留,因此,当天和时间不会有任何一次性保留。 我需要书写一种习俗,但我无法找到如何在保留表中增加信息,同时节省成员席位。 我想增加成员名称,使成员成为真正的成员,以确保其为成员保留。
class Member(models.Model):
DAY_CHOICES = (
(1, PAZARTESI ),
(2, SALI ),
(3, CARSAMBA ),
(4, PERSEMBE ),
(5, CUMA ),
(6 , CUMARTESI ),
(7, PAZAR ),
)
name = models.ForeignKey(User)
starting_date = models.DateField()
end_date = models.DateField()
day = models.IntegerField(max_length=1, choices=GUN_CHOICES)
field = models.ForeignKey(Field)
fee = models.DecimalField(decimal_places=0, max_digits=3)
def __unicode__(self):
return u %s %s, %s, %s % (self.name.first_name, self.name.last_name, self.day, self.field)
class Meta:
unique_together = (( date , field ))
请你帮助吗?
感谢。