FAQ Database Discussion Community


Django admin list display optimize queryset

python,django,optimization,admin,django-queryset
In User model i have a method: @cached_property def income(self): return PartnerIncome.objects.all().aggregate(Sum('income'))['income__sum']*self.share_of_profit PartnerIncome model: class PartnerIncome(models.Model): title = models.CharField(max_length=255) income = models.FloatField(default=0) Now i want to show 'inccome' in list_display=('income', ) at admin panel, but each object make extra query to database. How i can make PartnerIncome.objects.all().aggregate(Sum('income')) as a global...

django pass a predicate to filter funtion

django,django-queryset,django-1.7
I have the following code, as you can see only thing that changes is the function call point__distance_gte or point__distance_lte. Is there a way to externalise this function from calling code. def search(): if distance == 50: jobs = list(Job.objects.filter(point__distance_gte=(ref_pnt, D(**distance_from_point)))) else: jobs = list(Job.objects.filter(point__distance_lte=(ref_pnt, D(**distance_from_point))) So something like: def...

Django - negative query in one-to-many relationship

django,django-queryset
Given these models: class Profile(models.Model): name = models.CharField(max_length=50) class BlogPost(models.Model): name = models.CharField(max_length=50) created_by = models.ForeignKey(Profile, related_name='posts') class Comment(models.Model): blog = models.ForeignKey(BlogPost, related_name='comments') body_text = models.TextField() created_by = models.ForeignKey(Profile, null=True, blank=True, on_delete=models.SET_NULL) Given a profile, I want to find all of the blog posts created by that profile, where there...

Annotate in one model Django

django,django-queryset
See my model https://github.com/rg3915/morris/blob/master/myproject/core/models.py How to return percent 'uf' of total? Example: 'uf','quant' 'AM',8 'SP',9 'RJ',4 I try p=Person.objects.values('uf').annotate(quant=Count('uf', distinct=True)).values_list('uf','quant') print(p.query) but return SELECT "core_person"."uf", COUNT(DISTINCT "core_person"."uf") AS "quant" FROM "core_person" GROUP BY "core_person"."uf", "core_person"."first_name" ORDER BY "core_person"."first_name" ASC and i need SELECT "core_person"."uf", COUNT(DISTINCT...

How to make a dictionary of two sets of related objects in django?

django,django-queryset
In making a simple forum, I want to make a dictionary of topics along with their authors (Users who are OPs) to be sent to template containing list of topics. Here is the model: class Topic(models.Model): title = models.CharField(max_length=100) description = models.TextField(max_length=10000, null=True) forum = models.ForeignKey(Forum) created = models.DateTimeField() creator...

Django how to not use cached queryset while iterating?

python,django,django-queryset
I have a queryset which I iterate through in a loop. I use data from the queryset to change data inside the queryset which might be needed in a lter step of the loop. Now the queryset is only loaded once at the beginning of the loop. How can I...

Filter data using max value

python,django,django-models,django-queryset
I have a model consists of order field , I want to fetch that row who have max value for order. Class MyModel(models.Model): user = models.ForeignKey(User) order = models.IntegerField() Now let say I want to fetch records for user 1 , for this user total no of rows exist in...

How can I filter a Django Queryset on an extra field?

python,django,orm,django-queryset
Here is my Django model: from django.db import models class MyModel(models.Model): a = models.IntegerField() b = models.IntegerField() c = models.IntegerField() I want to retrieve all instances of this model in which a = 5 and b + c > 10. How can I do it? When I try this: print...

Getting variable from queryset

python,django,django-queryset
I have a ModelAdmin class, to which I have added a custom action called add_50_credits as follows: class TutorAdmin(admin.ModelAdmin): ... actions = ['add_50_credits'] def add_50_credits(self, request, queryset): queryset.update(account_balance+=50) What I am trying to do is add 50 to the account_balance of all users in the queryset. However, this code gives...

Django queryset always reload instances

python,django,django-models,django-queryset
I'm having some problems with a homemade caching descriptor and debugging I came up to this (strange) behaviour I can't figure out. Consider the following Django1.7 model (actually very simplified compared to my original project): class Step(models.Model): game = models.ForeignKey('Game', on_delete=models.PROTECT) number = models.PositiveIntegerField() is_active = models.BooleanField(default=False) def __str__(self): return...

Django: form to query database

django,django-forms,django-templates,django-views,django-queryset
I want a user be able to make this query: Tell me all the people, without Phd, with full time contract with a contract among two dates. that translated into Django is: Contract.objects.filter( person__is_doctor = False, type_contract = 'full', starting_date__gte = start_date, ending_date__lte = end_date ) How could I make...

Filter Django GenericRelation based on function on foreignkey

python,django,enums,django-queryset
I want to find attributes associated to my character that fit in various categories. Eventually I want this output: "Attributes": { "Physical": { "Level": 1, "Strength": 1, "Dexterity": 1, "Stamina": 1 }, "Mental": { "Level": 2, "Intelligence": 1, "Wits": 1, "Resolve": 1 }, "Social": { "Level": 3, "Presence": 1, "Manipulation":...

django 1.7 order by related field error

python,django,order,django-queryset
I'm fairly new to Django. I've a problem ordering queryset by a related model field. I've already seen the similar questions on stackoverflow but I'm stuck with this silly error, I would like have all the records from "MktIn" ordered by "nome" field from "Squadre" model The relation is one...

Django Simple Search on Foreign Key and Many to Many Fields

django,django-models,django-queryset
This snippet for a simple Django search works great but doesn't support searches on Foreign Key or Many to Many fields. How can I search FK and M2M?

Django Query __isnull=True or = None

django,django-models,django-queryset
this is a simple question. I'd like to know if it is the same to write: queryset = Model.objects.filter(field=None) than: queryset = Model.objects.filter(field__isnull=True) I'm using django 1.8...

Peculiar QuerySet behaviour when doing an 'AND' query

django,django-queryset
I have some peculiar behaviour when making a query. When using an "AND" filter it takes some 20-30 seconds after the query has completed to render to the screen. The following is a test function I have been using to try to isolate the problem. def reports_question_detail(request, q_id): question =...

How can I use a where clause with the sum of two fields

python,django,django-queryset
I need to sum two fields in each record and then if that sum is greater than 0 select the record. Here's what the model looks like: class Location(models.Model): day1 = models.IntegerField(default=0) day2 = models.IntegerField(default=0) day3 = models.IntegerField(default=0) day4 = models.IntegerField(default=0) day5 = models.IntegerField(default=0) day6 = models.IntegerField(default=0) day7 = models.IntegerField(default=0)...

Change of 'QuerySet' from Django 1.4 to 1.7

python,django,django-queryset,django-1.7,django-1.4
I'm trying to port an app from Django 1.4.15 -> 1.7.3 I've come to a problem where the app have a method in models.py def is_votable(self, user): ''' Decides if the user can vote for him/herself or not ''' if self.rated_by.all().__contains__(user): return False return True the problem I have is...

Django query with annotated conditional expression uses INNER JOIN. How do I get it to use OUTER JOIN?

django,django-queryset,django-orm,django-1.8
I have a "Meal" model with a foreign key to "Food". Each meal has a rating: good, bad, or indifferent. I want to query a list of all foods and annotate the count of each type of meal rating, but some foods have no meals yet, so I want the...

Django 1.8 conditional annotation results in INNER JOIN instead of LEFT OUTER JOIN

django,django-models,django-queryset,django-orm,django-1.8
The models: class Bar(GenericModel): ... class Foo(GenericModel): bar = models.ForeignKey(Bar, related_name='foo_bar') The query: bars = Bar.objects .prefetch_related('foo_bar') .annotate(sum_foo=Sum( Case( When(foo_bar__is_deleted=False, then='foo_bar__amount'), default=Value(0), output_field=IntegerField() ) ) ) The former results in an inner join: SELECT ... FROM "bar" INNER JOIN "foo" ON ( "bar"."id" = "foo"."bar_id" ) ... What I intend...

Django, exclude() function on list

python,django,list,django-queryset,exclude
I have a list and I would to remove from it all elements that are contained into an other list. So, I would to have something like to 'exclude' queryset but on a list. Now this is my code: list = Friend.objects.friends(self.request.user) i_am_blocking = User.objects.filter(blocks_received__user_blocking=self.request.user) is_blocking_me = User.objects.filter(blocks_set__user_blocked=self.request.user) blocked_users =...

Django - Filter queryset with child objects (ForeignKey)

django,django-queryset
I have 3 Models, and 2 of them correspond to the first one. class Parent(models.Model): name = models.CharField.... ... class Child1(models.Model): parent = models.ForeignKey(Parent) ... class Child2(models.Model): parent = models.ForeignKey(Parent) ... Now, in my view I have 2 querysets filtered of Child1 and Child2 objects. Is there a way to...

Django queryset filter filefield not empty

python,django,postgresql,django-queryset
I'm trying to filter a queryset, to exclude the one with no file. And I can't get it work, except by numberless iterations. class Something(models.Model): name = models.CharField(max_length=512) file = models.FieldField(upload_to="files", null=True, blank=True) then, to get the one with a file # this give me all objects Something.objects.exclude(file__exact='') # this...

Is it possible to use a variable as code in python

python,django,django-queryset
Almost 20 yrs ago when I learned perl, I remember you could us a variable as code. I am not sure why this isnt working so I would love to know if "interpolating a variable can become code" in python. for instance: def count_usages(): fields_ls = ['reporter', 'creator', 'assignee', 'duedate']...

Retrieving a specific field from Django query

django,django-models,django-queryset
I am trying to get the type field from filtering by name. So I am trying to do something like:Example.objects.get(type).filter(name_exact="Sheep") and it should return Animal But its not successful. models.py class Example(models.Model): type = models.CharField(max_length=50, choices=CATEGORY_TYPE) #i.e Class, Type, Commodity, Market, Breed name = models.CharField(max_length=50) def __str__(self): return u"%s" %...

Django updates that span relationships

django,django-queryset,django-related-manager
I would like to run an update query that spans several realtionships. Is this possible with django? This is what I have tried: from django.db.models import F Transaction.objects.filter(pk__lt=10).update( page__total_earned=F('page__total_earned')+5, page__profile__balance=F('page__profile__balance')+5 ) Here is a glimpse of my models in case you are wondering: class Transaction(models.Model): page = models.ForeignKey(Page, related_name='transactions', null=True,...

Using Django, how I can achieve this in a single query?

python,django,django-queryset,timedelta,django-aggregation
I have the following model: class Ticket(models.Model): # ... other fields omitted active_at = models.DateTimeField() duration = models.DurationField() Given now = datetime.now(), I'd like to retrieve all records for which now is between active_at and active_at + duration. I'm using Django 1.8. Here are the DurationField docs....

Efficient reverse of queryset

python,django,django-queryset,models
I'm trying to look at the most efficient way to traverse my models to get the data that I'm after. I have three "related" models. Item, ProtectionList and Player Protection List class ProtectionList(models.Model): player = models.ForeignKey(Player) main_hand = models.ForeignKey(Item, null=True, blank=True, related_name='main_hand') off_hand = models.ForeignKey(Item, null=True, blank=True, related_name='off_hand') head =...

Adding a value to a queryset in Django

python,django,django-queryset
In my Django form I have a ModelChoiceField for employees, but I want a choice in the dropdown for 'all' employees. What would be the best way to accomplish this? employees = forms.ModelChoiceField(queryset=Employees.objects.all()) First attemptI tried employees = forms.ChoiceField(choices = Employees.objects.values()) but I get a 'too many objects to unpack'...

Querying using Q objects

django,django-models,django-queryset
Hi I'm a newbie to Django. I'm trying to implement a search feature like this. query_results = Shops.objects.filter\ (Q(shop_name__icontains=search_text)\ |Q(state__state_name__icontains=search_text)\ |Q(city__city_name__icontains=search_text)).distinct() I would like to search Shops based on the shop_name, state_name and city_name. State and city fields are foreign keys. For some 'Shops' stateandcity are null. However, shop_name contains...

Why am I getting matching query does not exist?

django,django-queryset
I get the following error: DoesNotExist: PostalCode matching query does not exist on the line below: nearestzips = PostalCode.objects.distance(PostalCode.objects.get(code='self.zipcode').location) In an effort to troubleshoot the issue. I went into my python shell and was able to run: PostalCode.objects.distance(PostalCode.objects.get(code='97202').location) Which returned the proper zipcodes. I think what this means is that...

Django queryset filter model attribute against other model attribute

python,django,django-queryset
I don't know if I made myself clear with this question title, but, heres my problem: I have this model, which is just a transactional model: class InstanceItemEvaluation(models.Model): instance = models.ForeignKey(Instance) item = models.ForeignKey(InstanceItem) user = models.ForeignKey(User) factor = models.ForeignKey(Factor) measure = models.ForeignKey(Measure) measure_value = models.ForeignKey(MeasureValue, null=True, blank=True) evaluated_at =...

Django filter queryset if a field exists

django,django-queryset,django-filter
I want to filter my queryset if and only if loan exists in my model ShgGroupLoanMarking. class ShgGroupLoanMarking(models.Model): shg = models.ForeignKey(Shg, null=True) category = models.CharField(max_length=25, choices=GROUP_CATEGORY, default="shg_group") msss = models.ForeignKey(Msss, null=True) shgmember = models.ForeignKey(ShgMember, null=True) loan = models.ForeignKey(Loan, null=True) date_of_marking = models.DateField(null=True) paid = models.CharField(max_length=100, null=True) loan_amount = models.CharField(max_length=100, null=True)...

django - OR query using lambda

django,django-queryset
I want to perform OR query using django ORM. I referred this answer and it fits my need. I have a list of integers which gets generated dynamically. These integers represent user id in a particular table. This table also has a date field. I want to query the database...

Django Optimisation of a queryset with Q objects

sql,django,django-queryset
I'm using Django 1.8. I have a queryset that requires a logical "or" and an "and". It gives : MyModel.objects.filter( Q(start__gt=today) | Q(end__lte=today), active=True).update(active=False) As you may understand it, it should take every active MyModel instances which shouldn't have already started, and the one that have finished, and deactivate them....

How to get simple ForeignKey model working? (a list of class in another class)

django,django-models,django-queryset
I tried to figure this out on my own :( couldn't quite get there. Pls take pity. . . I'm trying to represent exercise data (a start time an end time and many--an undetermined number of-- heart rates) this is the model I have set up: class HeartRate(models.Model): timestamp =...

How to count users in JOINed models?

python,django,join,django-models,django-queryset
Let's say, we have two models: class User(models.Model): nickname = models.CharField(max_length=50) email = models.CharField(max_length=50) class Profile(models.Model): user = models.OneToOneField(User, primary_key=True) carma = models.BooleanField(default=False) birthdate = models.DateField(input_formats=['%Y-%m-%d']) How to get amount of users where: 1) all users with ages below 18? 2) all users between 18 - 25 3) all users...

Django annotate on another distinct field in queryset

django,django-queryset
I have a model as follows: class Task(models.Model): value= models.IntegerField() data = models.CharField(max_length=50, blank=True) I want to make a query to return the sum of the values for every distinct data. I tried the following but it didn't work: Task.objects.all().distinct('data').annotate(value = Sum('value')) I was getting this error: NotImplementedError: annotate() +...

Django custom annotation function

python,django,django-queryset
I want to build a simple hot questions list using Django. I have a function that evaluates "hotness" of each question based on some arguments. Function looks similar to this (full function here) def hot(ups, downs, date): # Do something here.. return hotness My models for question and vote models...

Can I delete an item of a queryset in python but without deleting that item on the database?

python,delete,django-queryset
I am creating an app in django, and I have the next problem: I get a queryset using the next command line: queryset = Persons.objects.all() Assume the resulting list is the next one: ['x', 'y', 'z'] And I want to remove an element x of that list, so that the...

How to write filter() once and reuse everywhere in Django

python,django,django-queryset
I want to write a filter once and reuse it everywhere, how can I do it? For example: there is a model Student with flag field. I want to write a filter to get non-graduate students (flag=0). But in many views and functions we need list non-graduate students, and I...

Django ANDing queryset filters using variable assignment

django,django-queryset
Let's say I have a queryset of Products that has tons of prefetch objects in it. Among the prefetch objects are "categories", and categories can have "filters". Not every Product has categories and filters defined. Example categories could be "price" and "color", and filters could be "lt $5" and "blue"....

Find what customer has spent the most money across multiple payments

python,django,django-models,django-queryset
So I have a model called Purchases and I need to find who are the top paying customers by adding up all there payments. The method I currently have is rather retarded and I know it can be shrunk massively, what would be the best method for this? For example:...

Django annotate raising AttributeError 'object has no attribute'

django,django-queryset
Hi I'm trying to use django's annotate and I think I'm doing everything ok but I must be missing something because I'm getting an Attribute Error Here are my models class Operation(models.Model): ... class Message(models.Model): operation = models.ForeignKey(Operation) sent_on = models.DateTimeField(auto_now_add=True) ... And here is what I'm trying to do:...

How to list objects in many to many Django

django,many-to-many,django-queryset
Considerer this model class Dealership(models.Model): dealership = models.CharField(max_length=50) class Ordered(models.Model): customer = models.ForeignKey("Customer") dealership = models.ManyToManyField("Dealership") status = models.CharField(max_length=2, choices=status_list, default='p') I try $ ./manage.py shell >>> from new_way.core.models import Ordered, Dealership >>> q = Ordered.objects.all()[:5] >>> [i.dealership for i in q.dealership.all] And generate error Traceback (most recent call last):...

Shuffle queryset in Django

python,django,django-queryset
I am looking to shuffle only part of queryset in django. qs = [obj1(order=0), obj2(order=1), obj3(order=999), obj4(order=999), .....] queryset is ordered by 'order' field which can be anything from 0 - 999. the final result should be all objects that are not 999 will be ordered from 0 and up,...

Why is my chained Django queryset not working?

django,django-queryset
latest_entries = Entry.objects.filter( zipcode=request.user.my_profile.nearbyzips1 ).filter( zipcode=request.user.my_profile.nearbyzips2 ).filter( zipcode=request.user.my_profile.nearbyzips3 ) This does not seem to return any Entry objects, even though it should. Note: If I were to remove all the chaining it just leave the initial nearbyzips1 filter, it returns all Entry objects that match that zipcode. So this tells...

how to limit the queryset of an inline model in django admin

python,django,inline,django-queryset,django-admin-filters
I have two models implemented like class A(models.Model): a_name = models.CharField(max_length=50) class B(models.Model): a = models.ForeignKey(A) b_tag = models.CharField(max_length=50) user=models.ForeignKey(User) # stores username now i define a A admin and register it with B as a subclass to TabularInline.I wonder if it is possible somehow to filter the list of...

Django queryset return different value for the same element

python,django,django-queryset
I'm baffled... here is what I get if I'm querying a very simple model: python manage.py shell In [1]: from tm_repository.models import TMTable In [2]: a=TMTable.objects.filter(sourceVC__contains='this activates the function for stating the access level of the input') In [3]: a.count() Out[3]: 8 In [4]: a[7].sourceVC Out[4]: u'Select {1}{2}2{3}{4}; this activates...

Django max based on foreign key queryset

python,django,django-queryset,annotate
I would like to annotate a queryset based on a foreign key, i.e. class A(models.Model): name = models.CharField(max_length=200) class B(models.Model): value = models.IntegerField() a = models.ForeignKey(A) I would like to annotate the B queryset with Max, but each Max being filtered to the a foreign key. I have a feeling...

Django filtering based on optional parameters

python,django,django-queryset
I have a list of optional parameters that I am using to filter in Django and am trying to come up with the best solution to apply these filters. My very first thought was to do something like: if param_1 != 'all' and param_2 != 'all': # etc. class_var =...

Django Querysets - Using .annotate() after .extra()

django,django-queryset,django-orm
Let us say I have a very simple model like this one: class Test(models.Model): category = models.CharField(unique=True) start_time = models.DateTimeField() end_time = models.DateTimeField() Basically, I want to use Django's ORM API to get the average duration per category. The SQL query will look something like this: SELECT category, AVG(end_time -...

Django QuerySet to return unique objects in ManyToMany fields

django,orm,django-queryset
Given the following models: class Author(models.Model): name = models.CharField() class Book(models.Model): title = models.CharField() published_year = models.PositiveIntegerField() authors = models.ManyToManyField(Author) Let's say I want to get all of the authors who have authored a book published in the year 2008. I can do the following: Book.objects.filter(published_year=2008).values_list('authors__name').distinct() That'll get me a...

Django Edit Form Queryset made of Query + Current Selected Option - How to get?

python,django,forms,django-queryset
My forms.py class CreateVesselForm(forms.ModelForm): class Meta: model = Vessel exclude = ['active'] # Filtering Choices def __init__(self, *args, **kwargs): super(CreateVesselForm, self).__init__(*args, **kwargs) # Filtering just Free Slots self.fields['slot'].queryset = Slot.objects.filter(is_free=True) # Filtering just Free Storages self.fields['storage'].queryset = Storage.objects.filter(is_free=True) The Slot Field is a ForeignKey and the Storage Field is a...

Django QuerySet contains duplicate entries

django,python-3.x,django-queryset
I'm trying to retrieve some of the contents of a table using django's ORM. results = Table.objects.using('production').filter(foreign_id=76) results.count() # 129807 The id column of this table is the primary key and thus, has unique entries. However, the returned QuerySet has duplicate entries: results[7999].id # 27177397 results[121679].id # 27177397 It's not...

Use get_object() and aggregate() in DetailView in Django

python,django,django-models,django-views,django-queryset
I have a DetailView in Django. In my template I'm printing the fields in my object dictionary, e.g. object.full_name. But I also want some aggregates belonging to the object. If say I have a model Person and a model Group and the model Group has a foreign key to Person,...

Like matching query does not exist - Django

python,django,django-models,django-views,django-queryset
I have created a like button that adds a user to a query when they like the photo, and removes them if they unlike the photo. The back-end works great! The front-end, not so much. I get the following error when I try to load the page: Like matching query...

sorting a reduce query with multiple terms and Q filters

python,django,python-2.7,django-queryset,searchqueryset
I am trying to make a search function that querys on multiple attributes from a model. To make matters a bit tougher I want to be able to do it with multiple terms inside a list comprehension then sort by the results that hit more accurately. For example, if the...

Django getting especific object using QuerySet in reverse relationship many-to-one

python,django,django-queryset,django-orm,many-to-one
Lets say I have the following models: Chat(models.Model): community = models.ForeignKey(Community, related_name="chats", null=True, blank=True) .... Community(models.Model): slug = models.CharField(max_length=250, unique=True, default='') .... Profile(models.Model): public_name = models.CharField(max_length=20, unique=True) community_subscriptions = models.ManyToManyField('Community', through='CommunitySubscription') chat_subscriptions = models.ManyToManyField('Chat', through='ChatSubscription') .......

I want to use the django ORM to get a complement from two tables

python,django,orm,django-queryset,set-theory
I aready have checked this question Getting complement of queryset. But, it didn't work. It seems like it's only extracting one field in the result. I have the following two tables: table A 001 a 002 b 003 C table B 001 a 002 b 003 c 004 d 005...

Django/Postgres: FATAL: remaining connection slots are reserved for non-replication superuser connections

python,django,postgresql,heroku,django-queryset
Recently I've been receiving this error regarding what appears to be an insufficiency in connection slots along with many of these Heroku errors: H18 - Request Interrupted H19 - Backend connection timeout H13 - Connection closed without response H12 - Request timeout Error django.db.utils.OperationalError in / FATAL: remaining connection slots...

Why won't my django queryset work?

django,django-queryset
I am trying to run a queryset with the value of the filter being the values inside a dictionary. latest_entries = Entry.objects.filter(zipcode__in=nearestzips.values()) print latest_entries >>>TypeError: Cannot use a multi-field GeoValuesQuerySet as a filter value. second attempt latest_entries = Entry.objects.filter(zipcode__in=nearestzips.values_list('code', flat=True)) print latest_entries >>>ProgrammingError: invalid reference to FROM-clause entry for table...

is ValuesQuerySet an evaluated form of queryset?

django,django-queryset
When you perform certain operations on queryset such as len or slicing, you hit DB and query is evaluated. Is ValuesQuerySet returned from values() or values_list() already evaluated? i.e. Did it already hit DB?...

Django QuerySet querying or filtering “Odd” and/or “Even” value in a particular field

python,django,python-3.x,django-queryset
# Example from django.db import models class ParkingLot(models.Model): lot_number = models.IntegerField() is_reserved = models.BooleanField() I'm interested in Odd xor Even lot_number. What's the recommended way to filter that in Django? I've posted some answer below. Challenge Does anyone know if we can use a direct comparison something like F('lot_number') %...

Django: bigger querysets & small no. of database hits or vice versa

mysql,django,django-queryset,django-orm
I am developing a website on django & MySQL which is similar to linkedin in terms of complexity and functionality and am expecting steep growth for a few months. I have one question. While designing the models and the views, I have two options. Either go for smaller number of...

Django - queryset caching request-independent?

python,django,django-queryset,django-cache
I need to cache a mid-sized queryset (about 500 rows). I had a look on some solutions, django-cache-machine being the most promising. Since the queryset is pretty much static (it's a table of cities that's been populated in advance and gets updated only by me and anyway, almost never), I...