Fabricio_Covalesci

Untitled

Oct 26th, 2020
647
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from django.db import models
  2.  
  3.  
  4. class AddresState(models.Model):
  5.     state = models.CharField(max_length=2)
  6.  
  7.  
  8. class AddressCity(models.Model):
  9.     city = models.CharField(max_length=100)
  10.     state = models.ForeignKey(AddresState, on_delete=models.CASCADE)
  11.  
  12.  
  13.  
  14. class AddressNeighborhood(models.Model):
  15.     neighborhood = models.CharField(max_length=100)
  16.     city = models.ForeignKey(AddressCity, on_delete=models.CASCADE)
  17.  
  18.  
  19.  
  20. class AddressStreet(models.Model):
  21.     street = models.CharField(max_length=100)
  22.     cep = models.CharField(max_length=12)
  23.     neighborhood = models.ForeignKey(AddressNeighborhood, on_delete=models.CASCADE)
  24.  
  25.  
  26.  
  27. class Address(models.Model):
  28.     state = models.ForeignKey(AddresState ,on_delete=models.CASCADE, null=True, blank=True)
  29.     city = models.ForeignKey(AddressCity ,on_delete=models.CASCADE, null=True, blank=True)
  30.     neighborhood = models.ForeignKey(AddressNeighborhood ,on_delete=models.CASCADE, null=True, blank=True)
  31.     street = models.ForeignKey(AddressStreet ,on_delete=models.CASCADE, null=True, blank=True)
  32.     number = models.CharField(max_length=8, null=False, blank=False)
  33.  
  34.     def __str__(self):
  35.         return self.street
RAW Paste Data