Models
This commit is contained in:
3
project/main/models/__init__.py
Normal file
3
project/main/models/__init__.py
Normal file
@ -0,0 +1,3 @@
|
||||
from .area import Area
|
||||
from .county import County
|
||||
from .post_office import PostOffice
|
||||
11
project/main/models/area.py
Normal file
11
project/main/models/area.py
Normal file
@ -0,0 +1,11 @@
|
||||
from django.db import models
|
||||
|
||||
|
||||
class Area(models.Model):
|
||||
name = models.CharField(max_length=100)
|
||||
post_office = models.ForeignKey("PostOffice", on_delete=models.CASCADE)
|
||||
county = models.ForeignKey("County", on_delete=models.CASCADE)
|
||||
|
||||
class Meta:
|
||||
db_table = "areas"
|
||||
ordering = ["name"]
|
||||
9
project/main/models/county.py
Normal file
9
project/main/models/county.py
Normal file
@ -0,0 +1,9 @@
|
||||
from django.db import models
|
||||
|
||||
|
||||
class County(models.Model):
|
||||
name = models.CharField(max_length=100)
|
||||
|
||||
class Meta:
|
||||
db_table = "counties"
|
||||
ordering = ["name"]
|
||||
10
project/main/models/post_office.py
Normal file
10
project/main/models/post_office.py
Normal file
@ -0,0 +1,10 @@
|
||||
from django.db import models
|
||||
|
||||
|
||||
class PostOffice(models.Model):
|
||||
zip = models.PositiveIntegerField()
|
||||
name = models.CharField(max_length=100)
|
||||
|
||||
class Meta:
|
||||
db_table = "post_offices"
|
||||
ordering = ["zip"]
|
||||
Reference in New Issue
Block a user