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 =

Re: Basic SQL

2008-11-04 Thread Tonne
I must have read that section ten times, but not seen the wood for the trees in my haste to find the right approach. It's making more sense to me now. Thanks again. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups

Re: Basic SQL

2008-11-04 Thread Daniel Roseman
On Nov 4, 9:50 am, Tonne <[EMAIL PROTECTED]> wrote: > Daniel, thank you (x100)! That was exactly what I was looking for. > > > {% for entry in entries %} > > {{ entry.title }} > >     {% for image in entry.image_set.all %} > >     > >     {% endfor %} > > {% endfor %} > > Now, could I ask what

Re: Basic SQL

2008-11-04 Thread Tonne
Daniel, thank you (x100)! That was exactly what I was looking for. > {% for entry in entries %} > {{ entry.title }} >     {% for image in entry.image_set.all %} >     >     {% endfor %} > {% endfor %} Now, could I ask what the name of the concept is that allows "image_set" to spontaneously

Re: Basic SQL

2008-11-04 Thread Daniel Roseman
On Nov 4, 7:45 am, Tonne <[EMAIL PROTECTED]> wrote: > I think I may be barking up the wrong tree, and if so please excuse > the above. I now suspect that I should be associating the images with > their relevant entries with template tags. You don't even need to do that. Assuming you have a

Re: Basic SQL

2008-11-03 Thread Tonne
I think I may be barking up the wrong tree, and if so please excuse the above. I now suspect that I should be associating the images with their relevant entries with template tags. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the

Basic SQL

2008-11-03 Thread Tonne
*disclosure* I am SQL novice, okay */disclosure* I have what I think is a very simple problem, but can't seem to find a solution without writing raw SQL. I have 2 (simplified here) models: class Entry(models.Model): title = models.CharField(max_length=80) class Image(models.Model):