Skip to main content
0 votes
0 answers
69 views

I am trying to annotate a queryset with next_service = last_service + verification_periodicity_in_days and then filter by that date. I am on Django 5.2.6 with PostgreSQL. last_service is a DateField. ...
Richard AR's user avatar
1 vote
1 answer
46 views

I'm refactoring a legacy Django Job to use annotate with filtered Count aggregations instead of querying each record individually (avoiding the N+1 problem). I want to count the number of related ...
Raul Chiarella's user avatar
3 votes
1 answer
78 views

I'm building a secure OTP system in Django. The model looks like this: class OTP(models.Model): MAX_ATTEMPTS = 3 DEFAULT_EXPIRE_IN_MINUTES = 1 class Purposes(models.IntegerChoices): ...
Ertugrul's user avatar
  • 175
0 votes
1 answer
42 views

I'm encountering a ValueError in my Django application when trying to save a User object with a related UserRoleAssociation in the admin interface. The error occurs in a multi-database setup where ...
mirodil's user avatar
  • 439
2 votes
1 answer
95 views

If I have, for example: from django.contrib.postgres.fields import JSONField class MyModel(models.Model): data = JSONField() GIVEN a model instance obj1, where data == ['apple', 'banana', '...
Dane Iracleous's user avatar
1 vote
1 answer
60 views

I have this model: class KeyAccessLog(models.Model): key = models.ForeignKey( Key, related_name="access_logs", on_delete=models.CASCADE ) path = models.CharField(...
Mirza Delic's user avatar
  • 4,381
-3 votes
1 answer
83 views

I am trying to work out if it's possible/practical to use the Django ORM to get the highest value in an arbitrary timebox out of the database. Imagine a restaurant orders ingredients every day, we ...
David Downes's user avatar
  • 1,209
0 votes
0 answers
44 views

I'm not sure if the title of this post made you understand the problem but let me explain: I have models: class ItemCategory(models.Model): name = CharField() class Item(models.Model): brand =...
Antony_K's user avatar
  • 196
0 votes
1 answer
35 views

I have a simple queryset resulting from this: Books.objects.all() Books is related to Authors like this: Class Books: ... author = models.ForeignKey(Authors, on_delete=models.CASCADE) Class ...
Riccardo Lamera's user avatar
-1 votes
1 answer
41 views

class Company_Car(models.Model): @property def days_left(self): print("RUNNED PROPERTY") if self.date_valid is not None and self.date_valid >= datetime....
Yuretz's user avatar
  • 129
1 vote
3 answers
120 views

I have two model instances, rec1 and rec2, but each has different fields updated: rec1 = MyModel(id=1, name="John") # Only 'name' is changed rec2 = MyModel(id=2, age=30) # Only 'age'...
Shrijan's user avatar
  • 19
0 votes
1 answer
71 views

I'm trying to implement a simple search for data on a website. If we specify the a tag in the "search_results.html" template, then all the information that is in it is not displayed, but if ...
user28264793's user avatar
3 votes
1 answer
99 views

We are migrating our django app from django==3.2.25 to django==5.1.6. OneToOneField, ManyToManyField are giving errors on revers lookup. Create fresh setup. python -m venv app_corp_1.0.X ./app_corp_1....
NPatel's user avatar
  • 21.4k
0 votes
0 answers
103 views

Other related Questions mention using either django.db's close_old_connections method or looping through the django connections and calling close_if_unusable_or_obsolete on each. I've tried doing this ...
George's user avatar
  • 4,164
0 votes
1 answer
137 views

I'm using Func() Expressions to use this answer and compute the difference between two dates in business days: class BusinessDaysBetween(Func): """Implementation of a Postgres ...
Genarito's user avatar
  • 3,493

15 30 50 per page
1
2 3 4 5
272