models.py 523 B

1234567891011121314151617181920
  1. from django.db import models
  2. class NationalRegion(models.Model):
  3. name = models.CharField(max_length=255)
  4. nuts_code = models.CharField(max_length=255)
  5. def __str__(self):
  6. return self.name
  7. class County(models.Model):
  8. name = models.CharField(max_length=255)
  9. code = models.CharField(max_length=255)
  10. nuts_code = models.CharField(max_length=255)
  11. region = models.ForeignKey(NationalRegion, on_delete=models.CASCADE, related_name='counties')
  12. def __str__(self):
  13. return self.name