Skip to content

Tag: django

How can I translate SQL query to to django ORM

I’m working on making some data consults in Django but I don’t understand quite well its ORM system yet. I need to get the transactions’ quantity for a particularly transaction’s projections. To put it briefly, I want to translate this SQL query to Python/Django syntax: These are the m…

ValueError could not convert string to float: ”

I’m having my app on heroku. I use timeme js to record user’s active time spend on the page, and use a hidden form to store the value into the database. Additionally, I’m using otree package to write my app. The following is the code I use: models.py views.py/pages.py in otree html The error…

uwsgi can’t be installed

I’m stuck trying to install uWSGI to deploy my Django application using pip install uwsgi, but encounter this error: I’ve found several answers that unfortunately didn’t work for me, like update dev tool ,install cywin or modify uwsgiconfig.py (which doesn’t exist since it’s not …

Django Exif Data: ‘IFDRational’ object is not subscriptable

I got an issue with the code: ‘IFDRational’ object is not subscriptable Here is the trace: the is issue is: Variable Value dms (45.0, 46.0, 34.29) ref ‘N’ That what I get from an image for instance. I think the code assimilate GPSLatitudeRef to degrees = dms[0][0] / dms[0][1]. The thin…

Difference between the __lte and __gte in Django

I am trying to figure out the difference between the __lte and __gte in Django. The reason being that I am trying to create a function with dates that can work only with a time frame, so I’ve been researching between Field Lookups Comparison. I’ve looked up several documentations https://docs.djan…

Use a decorator to add in a variable to request

I know the suggested way to do this is middleware, but I’d like to implement the following to add in an api_env variable, accessed at run-time, so that my view can access it: And the decorator: What’s the best way to do this? I have about 100 functions to wrap so I don’t want to add in a new…