0

I have a very simple vie in my django application

def notProjectsView(request):
context = {
    'projects':notProject.objects.all(),
    'title':'Not Projects | Dark White Studios'
}
return render(request, 'not-projects.html', context)

When I removed the context it ran fast, but it's a simple query and shouldn't be so long, the database also doesn't have a lot of records, it has 1 project and in the template I query project.notProjectImage.all which could cause an n+1 issue but I removed that part to test it and it was still slow Django debug toobar shows a ~50ms sql query while the actual request in the time tab is over 15 seconds

1 Answers1

0

So, you have eliminated the DB query as the reason it's slow. You need to look elsewhere. Is it slow when you test the view (using the Django test framework to GET html or POST data and check html response)? Then you've eliminated something happening in the browser, like a misbehaving script or framework. Which leaves the project's Python code, or something wrong with the machine it is running on. Is something looping far more than it ought to? Or is your developer machine page-thrashing because it is short of RAM?

(Oh, and where is the DB located? Developers usually host it on the machine they are developing with, but if it's cloud-based, look at the performance of the internet connection and possibly of the service itself).

Always work like Sherlock Holmes. "Once you eliminate the impossible, whatever remains, no matter how improbable, must be the truth."

BTW I recently traced occasional slowness on my developer machine to a bug in the (Cinnamon/Linux) GUI. That was of course the last place I though to look until I had eliminated absolutely everything else.

nigel222
  • 7,582
  • 1
  • 14
  • 22