Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class UsAddress(models.Model):
- #other fields
- zip = us_models.USPostalCodeField()
- country = models.CharField(max_length=2)
- phone = us_models.PhoneNumberField()
- def __unicode__(self):
- return self.zip + self.country + self.phone
- class MyType(models.Model):
- code = models.IntegerField()
- address = UsAddress
- def __unicode__(self):
- return str(self.code) + " - " + unicode(self.address) #self.address.__unicode__()
- <MyType: 219 - <class 'web.models.UsAddress'>>
- mt = models.ForeignKey(MyType)
- class MyType(models.Model):
- code = models.IntegerField()
- address = UsAddress
- def __unicode__(self):
- return u'%s - %s' % (self.code, self.address)
- <p>My object: {{ mytype_obj }}</p>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement