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.
我需要保持街道地址的线性断裂,但仍能够搜索这些地址。
我看到这样做的两种方式:
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()
或者在单一文本领域储存街道地址但使用特殊分离特性打上条码线的照片:
class Address(models.Model):
street = models.TextField()
city = models.TextField()
province = models.TextField()
code = models.TextField()
在法典的可读性和效率(或两者的平衡)方面,这样做的最佳方式是什么?