ajout des foreignKey

This commit is contained in:
maxime 2019-06-01 15:12:23 +02:00
parent bc6eda7a15
commit 8a31d698b5
1 changed files with 53 additions and 3 deletions

View File

@ -25,6 +25,7 @@ class Company(Model):
nationality = CharField(max_length=50)
email = EmailField(max_length=200)
phone = CharField(max_length=20)
# Foreign keys
address = ForeignKey(Address)
@ -46,7 +47,16 @@ class Boat(Model):
picture = ImageField(upload_to=None, height_field=None, width_field=None, max_length=100)
# Foreign keys
insurance = Insurance()
boat_insurance = ForeignKey(BoatInsurance)
company = ForeignKey(Company)
class BoatInsurance(Model)
contract = IntegerField()
date = DateTimeField()
# Foreign keys
insurance = ForeignKey(Insurance)
boat = ForeignKey(Boat)
class Port(Model):
@ -54,6 +64,7 @@ class Port(Model):
# Foreign keys
address = ForeignKey(Address)
company = ForeignKey(Company)
class Dock(Model):
num = CharField(max_length=10)
@ -61,21 +72,34 @@ class Dock(Model):
width = DecimalField()
depth = DecimalField()
# Foreign keys
port = ForeignKey(Port)
class Plug(Model):
num = CharField(max_length=10)
amperage = DecimalField()
voltage = DecimalField()
# Foreign keys
port = ForeignKey(Port)
class Tap(Model):
num = CharField(max_length=10)
# Foreign keys
port = ForeignKey(Port)
class Stay(Model):
arrival = DateTimeField()
departure = DateTimeField('date published')
coming_from = CharField(max_length=200)
going_to = CharField(max_length=200)
# Foreign keys
boat = ForeignKey(Boat)
bill = ForeignKey(Bill)
class PaymentType(Model):
name = CharField(max_length=20)
@ -84,11 +108,37 @@ class Payment(Model):
date = DateTimeField()
amount = DecimalField()
# Foreign keys
pay_type = ForeignKey(PaymentType)
class Service(Model):
service_type = CharField(max_length=50)
class Bill_line(Model):
service = ForeignKey(Service)
class BillLine(Model):
quantity = DecimalField()
# Foreign keys
service = ForeignKey(Service)
bill = ForeignKey(Bill)
class Bill(Model):
num = IntegerField()
date = DateTimeField()
total = DecimalField()
class BillPayment(Model):
amount = DecimalField()
# Foreign keys
bill = ForeignKey(Bill)
payment = ForeignKey(Payment)
class Mooring(Model):
date = DateTimeField()
# Foreign keys
stay = ForeignKey(Stay)
dock = ForeignKey(Dock)
tap = ForeignKey(Tap)
plug = ForeignKey(Plug)