I have a model that is trying to join (sloppily) across 3 tables.  
KnownCategories are a "group by catalog" reduction of Product.catalog  
(because I thought it would be quicker but I don't know if I'm  
right)...they should join like this...

Product.catalog <------> KnownCategory.fk_name <------>  
MetaCategory.name


class Product(models.Model):
        asin = models.CharField(maxlength=200)
        title =  models.CharField(maxlength=200, db_index=True)
        catalog  =  models.CharField(maxlength=200, default='',  db_index=True)


class MetaCategory(models.Model):
        name =  models.CharField(maxlength=200, core=True,  db_index=True,  
unique=True)

class KnownCategory(models.Model):
        meta_category = models.ManyToManyField(MetaCategory)
        fk_name = models.ForeignKey(Product, to_field='catalog')


...from the above... I was trying to do something like this...

 >>> p = Product.objects.filter(metacategory__name='Book')
 >>> p
Traceback (most recent call last):
   File "<console>", line 1, in ?
   File "/Library/Frameworks/Python.framework/Versions/2.4/lib/ 
python2.4/site-packages/Django-0.95-py2.4.egg/django/db/models/ 
query.py", line 97, in __repr__
     return repr(self._get_data())
   File "/Library/Frameworks/Python.framework/Versions/2.4/lib/ 
python2.4/site-packages/Django-0.95-py2.4.egg/django/db/models/ 
query.py", line 430, in _get_data
     self._result_cache = list(self.iterator())
   File "/Library/Frameworks/Python.framework/Versions/2.4/lib/ 
python2.4/site-packages/Django-0.95-py2.4.egg/django/db/models/ 
query.py", line 171, in iterator
     select, sql, params = self._get_sql_clause()
   File "/Library/Frameworks/Python.framework/Versions/2.4/lib/ 
python2.4/site-packages/Django-0.95-py2.4.egg/django/db/models/ 
query.py", line 444, in _get_sql_clause
     joins2, where2, params2 = self._filters.get_sql(opts)
   File "/Library/Frameworks/Python.framework/Versions/2.4/lib/ 
python2.4/site-packages/Django-0.95-py2.4.egg/django/db/models/ 
query.py", line 574, in get_sql
     joins2, where2, params2 = val.get_sql(opts)
   File "/Library/Frameworks/Python.framework/Versions/2.4/lib/ 
python2.4/site-packages/Django-0.95-py2.4.egg/django/db/models/ 
query.py", line 622, in get_sql
     return parse_lookup(self.kwargs.items(), opts)
   File "/Library/Frameworks/Python.framework/Versions/2.4/lib/ 
python2.4/site-packages/Django-0.95-py2.4.egg/django/db/models/ 
query.py", line 734, in parse_lookup
     joins2, where2, params2 = lookup_inner(path, lookup_type, value,  
opts, opts.db_table, None)
   File "/Library/Frameworks/Python.framework/Versions/2.4/lib/ 
python2.4/site-packages/Django-0.95-py2.4.egg/django/db/models/ 
query.py", line 835, in lookup_inner
     raise TypeError, "Cannot resolve keyword '%s' into field" % name
TypeError: Cannot resolve keyword 'metacategory' into field
 >>>



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---

Reply via email to