from django.db import models from billing.models import BillingProfile ADDRESS_TYPE = ( ('billing', 'Billing'), ('shipping', 'Shipping') ) class Address(models.Model): billing_profile = models.ForeignKey(BillingProfile) address_type = models.CharField(max_length=120, choices=ADDRESS_TYPE) adress_line_1 = models.CharField(max_length=120) adress_line_2 = models.CharField(max_length=120, null=True, blank=True) city = models.CharField(max_length=120) country = models.CharField(max_length=120) code = models.CharField(max_length=120) def __str__(self): return str(self.billing_profile) def get_address(self): return "{line1}\n{line2}\n{city}\n{country}\n".format( line1=self.adress_line_1, line2=self.adress_line_2 or "", city=self.city, country=self.country )