python 2.7 - Convert generator (iterator) to django queryset -


i have django model property __iter__ returns generator (iterator), further want convert resulted iterator queryset, allows me further filtering on resulting queryset.

car = car.objects.get(id=45) # __iter__ returns car objects cars = car.__iter__() cars.filter(name='abc') ? 

the above throw error, because cannot filter generator(iterator).

also dont want convert generator(iterator) list of id's, can use in car.objects.filter()

any ideas on how solve above problem.

thanks

as said, if __iter__ method returns generator, not possible perform further queryset methods on it.

one option return ids , use id__in filter, you've said don't want that.

another option additional filtering in python instead of sql.

car = car.objects.get(id=45) # __iter__ returns car objects cars = car.__iter__() cars = [c c in cars in c.name='abc'] 

without knowing __iter__ does, can't offer other suggestions.


Comments

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

[C++][SFML 2.2] Strange Performance Issues - Moving Mouse Lowers CPU Usage -

ios - Possible to get UIButton sizeThatFits to work? -