SHARE
TWEET

Untitled

a guest Feb 20th, 2019 79 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class UsAddress(models.Model):
  2.     #other fields
  3.     zip = us_models.USPostalCodeField()
  4.     country = models.CharField(max_length=2)
  5.     phone = us_models.PhoneNumberField()
  6.  
  7.     def __unicode__(self):
  8.         return  self.zip + self.country + self.phone
  9.  
  10.  
  11. class MyType(models.Model):
  12.     code = models.IntegerField()
  13.     address = UsAddress
  14.  
  15.     def __unicode__(self):
  16.         return str(self.code) + " - " + unicode(self.address) #self.address.__unicode__()
  17.    
  18. <MyType: 219 - <class 'web.models.UsAddress'>>
  19.    
  20. mt = models.ForeignKey(MyType)
  21.    
  22. class MyType(models.Model):
  23.     code = models.IntegerField()
  24.     address = UsAddress
  25.  
  26.     def __unicode__(self):
  27.         return u'%s - %s' % (self.code, self.address)
  28.    
  29. <p>My object: {{ mytype_obj }}</p>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top