mirror of
				https://github.com/django/django.git
				synced 2025-10-31 09:41:08 +00:00 
			
		
		
		
	Simplified choices iterators in tests.model_fields.models.
This commit is contained in:
		
				
					committed by
					
						 Tim Graham
						Tim Graham
					
				
			
			
				
	
			
			
			
						parent
						
							2d3cc94284
						
					
				
				
					commit
					b5ecbf1e12
				
			| @@ -50,27 +50,12 @@ class Whiz(models.Model): | ||||
|     c = models.IntegerField(choices=CHOICES, null=True) | ||||
|  | ||||
|  | ||||
| class Counter: | ||||
|     def __init__(self): | ||||
|         self.n = 1 | ||||
|  | ||||
|     def __iter__(self): | ||||
|         return self | ||||
|  | ||||
|     def __next__(self): | ||||
|         if self.n > 5: | ||||
|             raise StopIteration | ||||
|         else: | ||||
|             self.n += 1 | ||||
|             return (self.n, 'val-' + str(self.n)) | ||||
|  | ||||
|  | ||||
| class WhizIter(models.Model): | ||||
|     c = models.IntegerField(choices=Counter(), null=True) | ||||
|     c = models.IntegerField(choices=iter(Whiz.CHOICES), null=True) | ||||
|  | ||||
|  | ||||
| class WhizIterEmpty(models.Model): | ||||
|     c = models.CharField(choices=(x for x in []), blank=True, max_length=1) | ||||
|     c = models.CharField(choices=iter(()), blank=True, max_length=1) | ||||
|  | ||||
|  | ||||
| class BigD(models.Model): | ||||
|   | ||||
		Reference in New Issue
	
	Block a user