kopia lustrzana https://gitlab.com/marnanel/chapeau
Person lookups return Persons correctly; they don't delegate to the right types yet
rodzic
d50333cc44
commit
8317f82a43
|
@ -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
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue