Relative Content

Tag Archive for pythonpython-3.xdjango

Performance Error with Django Import/export

I am experiencing a performance issue with Django import-export in my production environment. When importing a spreadsheet with around 3k rows, the process ends up with an

RelatedObjectDoesNotExist when trying to count number of objects in a Query Set

I know that this error is not unique to me. I have come across many posts asking what the error is and how to fix it. One of the answers I saw was to use hasattr on the returned objects in a for loop before you try to get the attribute of the object. The problem is, is that I actually want to count() on the QuerySet. I saw some other post use some Django model aggregate function inside of the query, but I don’t think that is appropriate or necessary here. The query should be literally as easy as:

Is this logic in Settings.py regarding database redunant

In the settings of a Django project I am working on this is the way the DATABASES has been set up. The person who has written this has explained that the if statement is a redundancy which doesn’t make sense to me. As far as my understanding goes if the try fails that the if will also fail because they are setting ‘default’ the same way? Is this if statement redundant:

Django View Not Returning 404 as Expected When Form is Submitted

I’m facing a strange issue with Django. I have set up a simple form in a template that submits to a view, but I’m not getting the expected 404 response. Instead, I’m being redirected to the URL http://localhost:8000/clear/ without seeing the 404 error.