Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a recursive field resolver #116

Open
GoogleCodeExporter opened this issue Mar 16, 2015 · 0 comments
Open

Add a recursive field resolver #116

GoogleCodeExporter opened this issue Mar 16, 2015 · 0 comments

Comments

@GoogleCodeExporter
Copy link

Let's say you have this hierarchy of models and I want to index the hostname 
and *all* the installations on each of the disks and slots of that specific 
host. Well, it doesn't seem to work. After looking at indexer.Field.resolve() I 
noticed there's no recursion at all, it's meant to handle only 2 levels of 
relationships.

Tip: did you look at django-piston's solution to this ?
http://bitbucket.org/jespern/django-piston/src/tip/piston/emitters.py#cl-90

# models.py
class Host(models.Model):
    hostname = models.CharField()

class Disk(models.Model):
    host = models.ForeignKey(Host)

class Slot(models.Model):
    disk = models.ForeignKey(Disk)

class Installation(models.Model):    
    slot = models.OneToOneField(Slot)
    product = models.CharField()

# index.py
class HostIndexer(Indexer):
   tags = [
       ('hostname', 'hostname'),
       ('product', 'disk_set.slot_set.installation.product'), # <-- Not working
   ]
space.add_index(Host, HostIndexer, attach_as='indexer')

Original issue reported on code.google.com by jonsibo...@gmail.com on 6 Jul 2010 at 10:29

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant