Skip to content

Doing lookups in a polyphormic model as attribute #157

@pbassut

Description

@pbassut

So, I have the following models:

class Task(PolymorphicModel):
    title = models.CharField(max_length=100)

class TaskTopic(Task):
    topic = models.ForeignKey(Topic, default=None, null=True)

class Event(models.Model):
    tasks = models.ManyToManyField(Task, db_table='event_tasks')

I wanna filter by the topic field. I tried something like this but it didn't work.

Event.objects.filter(tasks__instance_of=TaskTopic)

Any ideia of how to do this?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions