Take a look at the query again ...
It's right here:

INNER JOIN product_category T5 ON
(custom_satchmo_authorcategory.category_ptr_id = T5.id) WHERE
product_category.slug = ?

You can only have FROM once in a SQL query, and that is right here:

ROM custom_satchmo_bookcategory

The rest of that query is trying to join various tables on to the query to
pull in the necessary data you are requesting.

You've got a problem somewhere else, not in Django's ORM, as far as I can
tell. What do you mean it's a "built-in query"?

Could you actually share the Traceback of the error you are receiving.
Something funny is happening, certainly, but there's still not enough
information to see what that something is.

Thanks,

Bob

On Mon, Mar 23, 2009 at 1:10 PM, Jon <[email protected]> wrote:

>
> It's a built in query.  In the admin, I added an AuthorCategory, which
> worked fine.  Then I added a BookCategory and set the AuthorCategory
> as a parent, and got the error.  Here is the query that is generated:
>
> SELECT product_category.id, product_category.site_id,
> product_category.name, product_category.slug,
> product_category.parent_id, product_category.meta,
> product_category.description, product_category.ordering,
> custom_satchmo_bookcategory.category_ptr_id,
> custom_satchmo_bookcategory.parent_id FROM custom_satchmo_bookcategory
> INNER JOIN product_category ON
> (custom_satchmo_bookcategory.category_ptr_id = product_category.id)
> INNER JOIN django_site ON (product_category.site_id = django_site.id)
> INNER JOIN product_category T5 ON
> (custom_satchmo_authorcategory.category_ptr_id = T5.id) WHERE
> product_category.slug = ? ORDER BY django_site.domain ASC,
> custom_satchmo_bookcategory.parent_id ASC, product_category.ordering
> ASC, product_category.name ASC
>
> The problem is custom_satchmo_authorcategory.category_ptr_id.  That
> column exists, but you'll notice that table
> custom_satchmo_authorcategory is not included in the FROM anywhere.
>
> On Mar 23, 12:45 pm, Bob Waycott <[email protected]> wrote:
> > Nothing looks seriously amiss with the model code at first glance. Care
> to
> > share the query you are issuing that fails?
> > Thanks,
> >
> > Bob
> >
> > On Mon, Mar 23, 2009 at 12:30 PM, Jon <[email protected]> wrote:
> >
> > > This is the models.py for the relevant classes.
> >
> > > from django.db import models
> > > from django.contrib.auth.models import User
> > > from satchmo.product.models import Category
> > > from django.utils.translation import ugettext_lazy as _
> > > import config
> >
> > > class AuthorCategory(Category):
> > >    author = models.OneToOneField(User)
> > >    def _get_subtype(self):
> > >        return 'AuthorCategory'
> >
> > >    class Admin:
> > >        pass
> >
> > >    class Meta:
> > >        verbose_name = _('Author Category')
> > >        verbose_name_plural = _('Author Categories')
> >
> > > class BookCategory(Category):
> > >    parent = models.ForeignKey('AuthorCategory')
> > >    def _get_subtype(self):
> > >        return 'BookCategory'
> >
> > >    class Admin:
> > >        pass
> >
> > >    class Meta:
> > >        verbose_name = _('Book Category')
> > >        verbose_name_plural = _('Book Categories')
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Satchmo users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/satchmo-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to