Hi,

I am writing a question-and-answer app which serializes data in JSON.
I have Question, User, and Asking models.  Asking is the many-to-many
relationship table for Question and User, because the Asking
relationship may be more complicated than it seems.  (Several users
may ask, and re-ask the same question, and I need to store when the
question was asked, whether the asker is primary or secondary, publish
date for the question, etc.)

The problem comes when I serialize a Question.  I want to get the User
information in the serialized object.

Models:

class User(models.Model):
    alternate_id = models.CharField(max_length=200, null=True)
    identifier = models.CharField(max_length=200, null=True)

class Asking(models.Model):
    user = models.ForeignKey(User)
    question = models.ForeignKey(Question)
    is_primary_asker = models.BooleanField()

class Question(models.Model):
    text = models.TextField()
    user = models.ManyToManyField('User', through='Asking', null=True)

In the view:

questions = Question.objects.filter(**filters)
return serializers.serialize("json", questions)

That's not giving me anything but a user Id.

I looked at natural keys, but I'm using Django 1.1.1.

Thanks for any suggestions.

-Jim

-- 
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