I'm trying to make a webservice that outputs XML representation of
data from a model. The model itself looks roughly like this:

---------
class Product(models.Model):
    short_description=models.CharField(max_length=300)
    long_description=models.CharField(max_length=2000)
    price=models.DecimalField(decimal_places=2, max_digits=6)
    store=models.ForeignKey(Merchant)
    def __unicode__(self):
        return self.short_description

class Merchant(models.Models):
    name=models.CharField(max_length=20)
    zip=models.CharField(max_length=6)
    category=models.CharField(max_length=10)
    <various other fields>
   def __unicode__(self):
        return self.name
----------

What I've done so far is this:

----------
zip='12345'
category='food'
products_list=Product.objects.filter(store__zip=zip,
                                store__category=category)
xml=serializers.serialize("xml",products_list,field=('short_description','price','store'))

--------

It works, and I get XML back, but the 'store' data is just the id for
the Merchant table. What I want instead is the name of the store. I've
tried replacing 'store' with 'store.name' and 'store__name' to no
avail -- how can I get the XML serializer to return a data member of
the 'store' object instead of just a pointer to that object?

If it's not possible with serializer, what's the best way to do it?

Thanks
Andrew


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to