Comments (10)
All right then, thank you for your support @clokep
from django-querysetsequence.
Ok, seems like that code is probably going away from django forms in 3.2 or 3.3, we can implement the private property without worrying about django, and just remove it in a few years 😂
from django-querysetsequence.
@jpic What version is this with? I haven't changed anything in a while besides removing some Python 2 compatibility, but that was just some future imports and such I believe.
Did a change to django-autocomplete-light
break this?
from django-querysetsequence.
No change on my side, seems to have broken for the first time in DAL's pipeline on December 17th. It went un-noticed because it tests a commit that's in a branch and which broke a bunch of selenium tests and was abandoned.
ModelChoiceIterator comes from Django, and apparently it's checks if the qs has _prefetch_related_lookups to False to decide if it is going to call queryset.iterator().
# Can't use iterator() when queryset uses prefetch_related()
if not queryset._prefetch_related_lookups:
queryset = queryset.iterator()
TBH, it looks pretty hacky, I would rather see Django do queryset.iterator() in a try/except, and see iterator() raise an exception if the queryset uses prefetch_related() which seems to be the problem in the comment.
Anyway, I could trace usage of that attribute to as far as 2015, in a commit that's in Django 1.10, when everything was definitely working.
Still digging, I am trying to reproduce it in a test in QSS, where tox runs fine with Python 3.8 as far as with Django 1.10, with Django 1.11 I get a couple of failures, is it your case too or is it something wrong perhaps with my environment ?
Also, I've asked the django-developers mailing list if they an effort to make django.forms.models rely only the public API of QuerySet would be acceptable, to make projects like QSS easier.
from django-querysetsequence.
Also, I've asked the django-developers mailing list if they an effort to make django.forms.models rely only the public API of QuerySet would be acceptable, to make projects like QSS more easy to use in forms.
I mean, if QSS had to implement a method that says if yes or no calling iterator() is fine, it would be pretty easy for you right ?
Meanwhile, I would understand that you would not want to add a _prefetch_related_lookups attribute, and will try to monkey patch the QSS object with that to get things to work again for DAL users.
Have a great day
from django-querysetsequence.
I mean, if QSS had to implement a method that says if yes or no calling iterator() is fine, it would be pretty easy for you right ?
I usually try to update this with changes to the public API, yes. 👍
It looks like this is a compatibility issue with Django, which is rather unfortunate. I wouldn't be 100% against adding a _prefetch_related_lookups
, but would need to ensure that the definition of it is sane. For a situation where prefetch_related
is called on the QuerySetSequence
this is easy-ish to do, but you can also create a QuerySetSequence
with a QuerySet
that already has prefetch_related
called on it.
From the way it is used, it might be OK to define it as:
@property
def _prefetch_related_lookups(self):
return any(map(lambda qs: qs._prefetch_related_lookups, self._querysets))
from django-querysetsequence.
There's been no reply on the django-developpers thread, so we have two options:
- open a ticket and a PR on django
- just define _prefetch_related_lookups property like you did, knowing we might need to change it again some day
from django-querysetsequence.
@jpic Or both -- we add the property for now and file a ticket with Django?
If adding the property, please add a comment about why it is necessary (and add some unit tests!)
from django-querysetsequence.
We just got a reply from charettes, linking to ongoing changes on the QuerySet API that relate to the code we're having issues with: https://groups.google.com/g/django-developers/c/ADgUd6jRvdw/m/_ZnETNlcAAAJ Can't dig right now though
In another recent thread, they are also talking about adding a contains() method to QuerySet, thought you might want to know about it.
QuerySet.contains() thread: https://groups.google.com/forum/#!msg/django-developers/NZaMq9BALrs/OCNTh6QyCAAJ
Our thread: https://groups.google.com/g/django-developers/c/gpQROT-kimE/m/qPNPMUi8AAAJ
from django-querysetsequence.
This is fixed in 0.13 of django-querysetsequence.
from django-querysetsequence.
Related Issues (20)
- Retrieving related values doen't work after order_by() HOT 3
- Need help! How to pass the serializers with the QuerySetSequence? HOT 2
- Slicing issue HOT 6
- DJ1.10: TypeError: not_impl() got an unexpected keyword argument 'using' HOT 4
- NotImplementedError: QuerySequence does not implement get_compiler() HOT 8
- Implement distinct() HOT 8
- 'QuerySetSequence' object has no attribute '_cloning' HOT 3
- Using QuerySets from different databases is not supported HOT 7
- Broken support for DjangoFilterBackend?
- New Version HOT 3
- Support Django 3.0 ( / drop support for Django 1.11 / Python 2.7) HOT 5
- SyntaxWarning: "is not" with a literal. Did you mean "!="? HOT 6
- pip installing this package is still using django.utils import six HOT 1
- 'QuerySetSequence' object has no attribute 'query' HOT 1
- Support using `models.F` in `QuerySetSequence.order_by()` HOT 1
- Support asynchronous ORM methods
- Support Django 4.1 fields for `bulk_create()`
- Support prefetching in `iterator()`
- Support order_by with None value HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from django-querysetsequence.