Skip to content

Tag: django

‘unicode’ object has no attribute ‘utcoffset’

In my admin, I am getting errors for only one class, ‘unicode’ object has no attribute ‘utcoffset’. I have looked at a few other similar questions and have been unable to solve it. Any ideas on how to fix it? The traceback is below the class. Traceback: Answer The default value for you…

A query with 3 tables in django

I have 3 classes like this: My question is: How can I make a query to get the devices used by the person “name”? Which needs to pass through the uses class. Answer Life will be easier if you use ManyToManyField, i.e. add this field to the Person model: Then, to get the list, you just need to get t…

Django: Adding “NULLS LAST” to query

I would like to sort a model by using Postgresql’s “NULLS LAST” option. How could it be done? I tried something like MyModel.objects.all().extra(order_by=(‘-price’, ‘NULLS LAST’)) But I get “Cannot resolve keyword ‘NULLS LAST’ into field” Answe…

Aggregating save()s in Django?

I’m using Django with an sqlite backend, and write performance is a problem. I may graduate to a “proper” db at some stage, but for the moment I’m stuck with sqlite. I think that my write performance problems are probably related to the fact that I’m creating a large number of ro…