Re: Django and a basic SQL join

2009-05-08 Thread Malcolm Tredinnick
On Wed, 2009-05-06 at 13:14 -0700, jrs_66 wrote: > Thanks! This is a great starting point. My real queryset requires me > to go a few joins deeper, however. I will try nesting loops to get > there, but this seems frightfully like querying in a loop (maybe I'm > wrong, I'll check the end query

Re: Django and a basic SQL join

2009-05-06 Thread jrs_66
Phil, Thanks for the pointers. I guess my thinking on this is that if someone feels a question is too trite to warrant and answer, they shouldn't answer. I don't think this group is called 'advanced django users', thus I don't really feel bad for posting 'newbie' questions. I appreciate all

Re: Django and a basic SQL join

2009-05-06 Thread jrs_66
Thanks! This is a great starting point. My real queryset requires me to go a few joins deeper, however. I will try nesting loops to get there, but this seems frightfully like querying in a loop (maybe I'm wrong, I'll check the end query to find out). It also seems like a frightening amount of

Re: Django and a basic SQL join

2009-05-06 Thread Alex Koshelev
On Wed, May 6, 2009 at 8:48 PM, jrs_66 wrote: > > Hi, > > I have 2 models... > [skip] > > e = FlattenedCategory.objects.select_related('category').filter > (member_of_category=15) > > which works... This, however, doesn't > > e = e.category > > How do I access the related

Re: Django and a basic SQL join

2009-05-06 Thread Phil Mocek
On Wed, May 06, 2009 at 10:17:29AM -0700, jrs_66 wrote: > This is definitely the most angry forum I've ever seen... the > kicker is that the anger is almost always coming from the people > associated with the django project... hmmm.. In your previous thread, someone from the Django project

Re: Django and a basic SQL join

2009-05-06 Thread Clément Nodet
> > In your case e is a QuerySet, with multiple FlattenedCategory objects. > > So the proper code would be to loop through them: > > {{{ > for fc in e: >     fc.category_set > }}} > Indeed, but category being a ForeignKey field, {{{ for fc in e: fc.category }}} will work here. -- Clément

Re: Django and a basic SQL join

2009-05-06 Thread George Song
In your case e is a QuerySet, with multiple FlattenedCategory objects. So the proper code would be to loop through them: {{{ for fc in e: fc.category_set }}} On 5/6/2009 10:17 AM, jrs_66 wrote: > No... 'QuerySet' object has no > attribute 'category_set' > > George, > > I have read the

Re: Django and a basic SQL join

2009-05-06 Thread mamco
jrs_66: you may find some comfort in the http://ubuntuforums.org/forumdisplay.php?f=39 forum - not specific to django, but quite a friendly bunch and lots of python folks willing to assist with the learning process. tag your posts with 'django' On May 6, 2:17 pm, jrs_66

Re: Django and a basic SQL join

2009-05-06 Thread jrs_66
No... 'QuerySet' object has no attribute 'category_set' George, I have read the docs... MANY times... from the docs... 'Django also creates API accessors for the "other" side of the relationship -- the link from the related model to the model that defines the relationship. For example, a

Re: Django and a basic SQL join

2009-05-06 Thread George Song
On 5/6/2009 9:48 AM, jrs_66 wrote: > I have 2 models... > > class Category(models.Model): > name = models.CharField(max_length=255) > parent = models.ForeignKey('self', null=True) > has_children = models.BooleanField(default=False) > language = models.ForeignKey(Language,

Django and a basic SQL join

2009-05-06 Thread jrs_66
Hi, I have 2 models... class Category(models.Model): name = models.CharField(max_length=255) parent = models.ForeignKey('self', null=True) has_children = models.BooleanField(default=False) language = models.ForeignKey(Language, null=False, default=1) active =