mirror of
				https://github.com/django/django.git
				synced 2025-10-31 09:41:08 +00:00 
			
		
		
		
	Instead of loading all QuerySet results in memory, count the number of entries. This adds an extra query when list() or tuple() is called on the choices (because both call __len__() then __iter__()) but uses less memory since the QuerySet results won't be cached. In most cases, the choices will only be iterated on, meaning that __len__() won't be called and only one query will be executed.
		
			
				
	
	
	
		
			113 KiB
		
	
	
	
	
	
	
	
			
		
		
	
	
			113 KiB