Re: django join queries

2010-09-13 Thread nick.l...@gmail.com
Ok...context helps! :) Try reading this... http://docs.djangoproject.com/en/dev/topics/serialization/#deserialization-of-natural-keys I think that'll help get you where you need to go. n On Mon, Sep 13, 2010 at 2:19 PM, ashy wrote: > Hi Nick, > > I am trying to serialize the object and send i

Re: django join queries

2010-09-13 Thread ashy
Hi Nick, I am trying to serialize the object and send it to the calling ajax request users = Userdata.objects.all() HttpResponse(serializers.serialize('json', users), mimetype='application/json') in the javascript code, I do not get the user object to call u.username. I guess it wont work that

Re: django join queries

2010-09-13 Thread nick.l...@gmail.com
Ashy, The question what do you want to do with the data is important. When you do Userdata.objects.all() you will get back all the data from both tables. How you access it is different. u = Userdata.objects.all()[0] u.user.name is going to return the name from the User model. u being the UserDa

Re: django join queries

2010-09-13 Thread ashy
Yes, I know that. What is the object oriented way of getting the data from both the tables based on the foreign key? thanks for any help. -- 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...@googlegr

Re: django join queries

2010-09-13 Thread Daniel Roseman
On Sep 13, 12:26 pm, ashy wrote: > Ok, > > but I want to retrieve rows from both the tables based on the foreign > key. > User.objects.all() > or > Userdata.objects.all() > will give me data from either table. How can retrieve data from both > the tables using the foreign key? > > thanks >    ashy

Re: django join queries

2010-09-13 Thread ashy
Ok, but I want to retrieve rows from both the tables based on the foreign key. User.objects.all() or Userdata.objects.all() will give me data from either table. How can retrieve data from both the tables using the foreign key? thanks ashy -- You received this message because you are subscrib

Re: django join queries

2010-09-13 Thread Daniel Roseman
On Sep 13, 12:18 pm, ashy wrote: > Hi All, > > I have the following model class > > from django.db import models > from django.contrib.auth.models import User > > # Create your models here. > class Userdata(models.Model): >   user = models.ForeignKey(User) >   location = models.CharField(max_lengt

django join queries

2010-09-13 Thread ashy
Hi All, I have the following model class from django.db import models from django.contrib.auth.models import User # Create your models here. class Userdata(models.Model): user = models.ForeignKey(User) location = models.CharField(max_length=200) I want to join them on user foreign key. How