clokep / django-querysetsequence

Chain multiple (disparate) QuerySets in Django
https://django-querysetsequence.readthedocs.io/
ISC License
107 stars 25 forks source link

Implement distinct() #31

Open mauroka opened 7 years ago

mauroka commented 7 years ago

Hello, I'm trying to integrate django-querysetsequence with django-datatable-view (https://github.com/pivotal-energy-solutions/django-datatable-view)

When this component executes a search a NotImplementedError: QuerySetSequence does not implement distinct() error arrises.

So I would like to know if you plan to implement distinct in the future.

By the way, I fix it so when I use querysetsequence it doesn't use distinct, but of course, there are some duplicated results.

Thanks a lot for the help. Mauro.

clokep commented 7 years ago

@mauroka I don't have any plans to implement distinct() at the moment, it's not needed for my application. I could definitely set aside time to offer guidance and review a pull request implementing this though!

The real downside is that there probably isn't a sane implementation besides just caching all the results, which makes it incompatible with e.g. iterator().

mauroka commented 7 years ago

Hello @clokep, thanks for the response. Let me see if I can manage myself with an implementation without using distinct(). In case I require it, I will implement distinct() with your help. Thanks a lot. Mauro.

clokep commented 7 years ago

Sounds great! Let me know if you have more questions.

sanjeevjohal commented 6 years ago

@mauroka how did you fix the querysetsequence so that it doesn't use distinct?

clokep commented 6 years ago

@sanjeevjohal It probably depends on your specific application. I suspect this would be easier to implement now that the internals of QuerySetSequence are much simpler.

sanjeevjohal commented 6 years ago

@clokep I'm using it within an admin class where I've overridden the get_queryset method and when i use the ModelAdmin.list_filter I get this error or any other not implemented attribute (e.g when I try to use the date_heirarchy i get the aggregate attribute not supported).

Any help will be greatly appreciated. Many thanks.

PS. I'm a relatively new to Django and learning every day 😄

mauroka commented 6 years ago

@sanjeevjohal I modified django-datatable-view, not django-querysetsequence. Right now I'm migrating to this component https://bitbucket.org/pigletto/django-datatables-view-example/

sanjeevjohal commented 6 years ago

Thanks @mauroka.

@clokep I should add I'm still on v1.8 and have no plans to upgrade to v1.11 where you can now combine querysets using a union. I did try to use the set operator | but this didn't give me a union which I understand removes duplicates even after I deliberately made an attribute in both models different