I need to model a postal address that can have multiline street address, the city, the state (province), and the postal code. the country is omitted.
I need to preserve line breaks in the street addresses but still be able to search the addresses.
I see two ways to do it:
class Address(models.Model):
street = models.ForeignKey('StreetAddress')
city = models.TextField()
province = models.TextField()
code = models.TextField()<br>
class StreetAddress(models.Model):
line_number = models.IntegerField()
text = models.TextField()
or this one which stores the street address in a single text field but uses special separator characters to encode line breaks:
class Address(models.Model):
street = models.TextField()
city = models.TextField()
province = models.TextField()
code = models.TextField()
what is the best way to do it in terms of code readability and efficiency (or their balance)?