def one_line_address(self):
"""
Put the address all on one line
"""
import re
from django.utils.html import strip_tags
if self.street_address and self.city and self.state and self.zipcode:
# Since the street address is a text field, we have to clean it up a bit
# making sure HTML tags are removed, <BR> tags are converted to newlines
# and newlines are replaced with ', '
address = re.sub(r'<br\s*/?>', '\n', self.street_address)
address = strip_tags(address)
address_parts = address.splitlines()
address_parts.extend([
self.city,
self.state,
self.zipcode,
unicode(self.country.name),
])
return ", ".join(address_parts)
return ""
评论列表
文章目录