Re: Still really struggling with JOINS

2006-10-27 Thread Andy Dustman
On 10/27/06, Tom Smith <[EMAIL PROTECTED]> wrote: > Is there a way to do a complete dump, re-build the database and then > import stuff (avoiding import errors... i.e doing some form of > coercion)? Use mysqldump with the --no-create-info option which avoids dumping the table schemas. Drop the d

Re: Still really struggling with JOINS

2006-10-27 Thread Tom Smith
> Just to establish that we are all on the same page: are you seeing the > error when you use exactly the model example you posted yesterday and > cut and paste the queryset constructor that Rajesh posted? That should > be working. No, it fails for me, we are on the same page. > If that is fail

Re: Still really struggling with JOINS

2006-10-11 Thread Malcolm Tredinnick
On Wed, 2006-10-11 at 19:53 +0100, Tom Smith wrote: > > On 11 Oct 2006, at 18:59, Rajesh Dhawan wrote: [...] > > > > Perhaps try upgrading to a recent SVN of Django? I am on 0.96-pre. > > > > > I upgraded... > > > > > Also, I am using SQLite for the DB but that should not matter, I > > thi

Re: Still really struggling with JOINS

2006-10-11 Thread Tom Smith
On 11 Oct 2006, at 18:59, Rajesh Dhawan wrote:Hi, This still works for me! The only change I made to your model was to add a "class Admin: pass" to your ProductWord class so that I could add a ProductWord test object through the Admin UI. My results in the shell: from my_app.models import Produ

Re: Still really struggling with JOINS

2006-10-11 Thread Waylan Limberg
On 10/11/06, RajeshD <[EMAIL PROTECTED]> wrote: > > > > On Oct 11, 9:59 am, Tom Smith <[EMAIL PROTECTED]> wrote: > > Oops... replied to wrong thread... > > > > here it is... > > > > It has a lot of stuff... but the core is simple enough, like this... > > > > I just whipped up something based on yo

Re: Still really struggling with JOINS

2006-10-11 Thread RajeshD
On Oct 11, 9:59 am, Tom Smith <[EMAIL PROTECTED]> wrote: > Oops... replied to wrong thread... > > here it is... > > It has a lot of stuff... but the core is simple enough, like this... > I just whipped up something based on your model definition excerpts and it works perfectly with: Product.ob

Re: Still really struggling with JOINS

2006-10-11 Thread Tom Smith
Oops... replied to wrong thread... here it is... It has a lot of stuff... but the core is simple enough, like this... class Product(models.Model): title = models.CharField(maxlength=200, db_index=True) url = models.URLField(maxlength=250, db_index=True, unique=True)

Re: Still really struggling with JOINS

2006-10-10 Thread RajeshD
> > > Product.objects.filter > > (productword__fk_word__value__exact='thomas').distinct()When I try that... > > I get... > > TypeError: Cannot resolve keyword 'productword' into field That should work. Can you attach your model? --~--~-~--~~~---~--~~ You receive

Re: Still really struggling with JOINS

2006-10-10 Thread Tom Smith
On 10 Oct 2006, at 22:11, RajeshD wrote: > > See if this helps: > > Product.objects.filter > (productword__fk_word__value__exact='thomas').distinct() When I try that... I get... TypeError: Cannot resolve keyword 'productword' into field --~--~-~--~~~---~--~~ Y

Re: Still really struggling with JOINS

2006-10-10 Thread Steve M
Hi, I myself am learning this, but I'd like to take a crack at your question. Based on the DB API document, you need to employ both select_related() (to go from a model with a FK to the objects related by that FK), and somefield_set (to go the other way). (Note it seems select_related is a method

Re: Still really struggling with JOINS

2006-10-10 Thread RajeshD
See if this helps: Product.objects.filter(productword__fk_word__value__exact='thomas').distinct() --~--~-~--~~~---~--~~ 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

Re: Still really struggling with JOINS

2006-10-10 Thread Tom Smith
Or to put it more simply... all I'm trying to do is this... Select * from myapp_product, myapp_productword, myapp_word where myapp_productword.fk_product_id = myapp_product.id and myapp_productword.fk_word_id = myapp_word.id and value = 'assam' order by title ..returning Product objects... --

Still really struggling with JOINS

2006-10-10 Thread Tom Smith
My model is like this... class Product(models.Model): class Word(models.Model): value = models.CharField(maxlength=200, core=True, unique=True) class ProductWord(models.Model): fk_word = models.ForeignKey(Word , core=True) fk_product = models.ForeignKey(Produc