I have a query set of some 500 objects... which I get after running the initial query set in some loops and checking a few conditions and excluding the objects that do not meet the criteria... and I am displaying these objects using Django core pagination.. how efficient is this and if not, what are the alternatives.
EDIT: this code probably does not make sense. but this is how I am filtering the initial query set
projs = Model.objects.filter(user=user)
if request.user.is_authenticated:
for x in projs:
if x.restrictions: # restrictions is a string
split = x.restrictions.split(',')
for word in split:
checking = re.findall("@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+", request.user.username)[0]
if word == checking or word == request.user.username:
break
else:
projs = projs.exclude(id=x.id)
else:
for x in projs:
if x.restrictions:
projs = projs.exclude(id=x.id)