Familiarise yourself with the python command line ('manage.py shell')
and the querying docs, shouldn't take long.

http://docs.djangoproject.com/en/dev/topics/db/queries/


I like the improvements that ipython brings to the command line, but
that's not relevant.

Hope this helps



On Oct 16, 11:55 pm, eugened <[email protected]> wrote:
> Probably trivial question but I can't find the answer:
> My model consist of 2 objects:
> Profile and Folder
> One profile can have multiple folders
> My task is to display or serialize into json Profile and list of
> folders in one request.
> So far I get only parent fields(Profile) but not folders.
> I am new to Django, come from Java camp - please help.
> Thanks.
>
> My Model:
> class Profile(models.Model):
>     profileid = models.DecimalField(primary_key=True)
>     email = models.CharField(max_length=70, blank=True)
>     firstname = models.CharField(max_length=100, blank=True)
>     lastname = models.CharField(max_length=100, blank=True)
>
> class Folder(models.Model):
>     folderid = models.DecimalField(primary_key=True,unique=True)
>     owner = models.ForeignKey(Profile,db_column='ownerid')
>     name = models.CharField(max_length=100)
>
> My code in a view:
> def getUser(request,profile_id):
>     profile=get_object_or_404(Profile, pk=profile_id)
>     queryset=Profile.objects.select_related().filter(pk=profile_id)
>     json_serializer = serializers.get_serializer("json")()
>
>     json_serializer.serialize(queryset, ensure_ascii=False)
>     data = json_serializer.getvalue()
>
>     return HttpResponse(data,mimetype="application/json",status=200)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to