My code is as follows:
for p in qs: set = None try: set = p.property.property_locations.all() except IndexError: pass if set:
The problem is that when set is none, it still throws an IndexError from this part of django.db.models.query:
try: qs = self._clone() qs.query.set_limits(k, k + 1) return list(qs)[0] except self.model.DoesNotExist, e: raise IndexError(e.args)
How to stop the system from throwing this error and moving on to the next for for element?
python list django exception
moutone
source share