django - TastyPie ManyToMany not working -


i have been trying manytomany working in tastypie, th e link fails show up. simple relationship, family record multiple address records, when display family record via api, address doesn't show, though field , relationship doesn't exit.

can tell me i'm doing wrong

class family(models.model):     ''' family object table .     contacts link table, table has many many relationship     addresses '''     familyname = models.charfield(max_length=100, unique=true)     address = models.manytomanyfield('address')     active = models.booleanfield(default=true)      def __unicode__(self):         return self.familyname      class meta:         ordering = ['familyname']  class address(models.model):     ''' table hold addresses families, contacts , staff.      contact detail should here, phones, addresses, postal titles etc     stored in these records      '''     homesalutation = models.charfield(max_length=100)     postaltitle = models.charfield(max_length=100)     addressline1 = models.charfield(max_length=100)     addressline2 = models.charfield(max_length=200)     addressline3 = models.charfield(max_length=100, blank=true)     addressline4 = models.charfield(max_length=100, blank=true)     postcode = models.charfield(max_length=100)     country = models.charfield(max_length=100, null=true, blank=true)     phone1 = models.charfield(max_length=150, blank=true)     phone2 = models.charfield(max_length=150, null=true, blank=true)     phone3 = models.charfield(max_length=150, null=true, blank=true)     emailaddress = models.emailfield(blank=true)     note = models.textfield(blank=true)     active = models.booleanfield(default=true)      def __unicode__(self):         return u'%s , %s' % (self.postaltitle, self.postcode)      def listaddress(self):         returnaddress=''         if self.addressline1:             returnaddress+=self.addressline1         if self.addressline2:             returnaddress+=', %s' % (self.addressline2)         if self.addressline3:             returnaddress+=', %s' % (self.addressline3)         if self.addressline4:             returnaddress+=', %s' % (self.addressline4)         if self.postcode:             returnaddress+=', %s' % (self.postcode)         return returnaddress  class addressresource(modelresource):     class meta:         queryset=address.objects.all()         resource_name='address'         filtering = {             "homesalutation":all,             "postaltitle": all,             "addressline1": all,             "addressline2": all,             "addressline3": all,             "addressline4": all,             "postcode": all,             "phone1" : all,             "phone2": all,             "phone3": all,             "active": all,         }         authentication = basicauthentication()         allowed_methods = ['get']         cache=simplecache()  class familyresource(modelresource):     address = fields.tomanyfield('addressresource','address',null=true,full=true)     class meta:         queryset=family.objects.filter(active=true)         resource_name='family'         filtering = {             "id" : all,             "familyname" : all,         }         authentication = basicauthentication()         allowed_methods = ['get']         cache=simplecache() 

tastypie picky exposing foreign keys. suggest zapping familyresource.address reference, re-add using code tutorial.

http://django-tastypie.readthedocs.org/en/latest/tutorial.html#creating-more-resources


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -