[Answered ]-Django views error when deployed

2👍

Your problem is the profiles variable not being defined in production.

There is a code path that doesn’t define your profiles variable.

Upon closer look, you should be able to why it’s happening.

your qs may be empty, your assumption that request.method must be either get or post might be wrong. (client might send patch, delete request). There could be more reasons…

In any case, your code has holes that doesn’t define profiles variable, and your production server (or client using the server) is different in a sense that it is going through the different execution path.

You could put a import pdb; pdb.set_trace() and debug it.
or mentally analyse your code to fix it.

👤eugene

0👍

Put or copy the

paginator = Paginator(profiles,12)

under

profiles = UserProfile.objects.filter(f).order_by(‘-created_at’)

with the same indentation. I think the value of f is not None, and based-on dislayed code, your pagination is outside of the profile_search(), so i think the assignment of profilles failed.

👤pupil

Leave a comment