Person lookups return Persons correctly; they don't delegate to the right types yet

thingy_objects
Marnanel Thurman 2018-10-29 14:39:52 +00:00
rodzic d50333cc44
commit 8317f82a43
1 zmienionych plików z 12 dodań i 15 usunięć

Wyświetl plik

@ -9,25 +9,19 @@ class SomethingManager(models.Manager):
f_type = None
def get_queryset(self):
# XXX Make sure all QSs return url
# TODO augment QSs with contenttypes link to source
result = Cache.objects.filter(
f_type=self.f_type,
result = models.QuerySet(
model = self.parent_model,
)
print(list(result))
handlers = [
Cache.objects.filter(f_type=self.f_type),
]
# XXX Trouble: this returns everything as a Cache,
# whereas we want it to return a Person or whatever.
# XXX Make a list and pass the whole list to union() once.
# XXX Make a dummy first entry that returns zero Persons
# (or whatever) so it gets the type right.
for local_handler in object_type_registry[self.f_type]:
print(local_handler)
result = result.union(local_handler.objects.all())
print(list(result))
print('all')
handlers.extend([
h.objects.all()
for h in object_type_registry[self.f_type]])
return result
@ -41,3 +35,6 @@ class Person(models.Model):
class Meta:
managed = False
Person.objects.parent_model = Person # this is ugly