mirror of
				https://github.com/django/django.git
				synced 2025-10-31 09:41:08 +00:00 
			
		
		
		
	[3.1.x] Corrected custom model fields how-to.
get_prep_value() method is complementary of from_db_value(). Follow up toe9103402c0. Backport of52a0a03671from master
This commit is contained in:
		
				
					committed by
					
						 Mariusz Felisiak
						Mariusz Felisiak
					
				
			
			
				
	
			
			
			
						parent
						
							e6285cac83
						
					
				
				
					commit
					fb9add3c7d
				
			| @@ -541,8 +541,8 @@ Converting Python objects to query values | ||||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||||
|  | ||||
| Since using a database requires conversion in both ways, if you override | ||||
| :meth:`~Field.to_python` you also have to override :meth:`~Field.get_prep_value` | ||||
| to convert Python objects back to query values. | ||||
| :meth:`~Field.from_db_value` you also have to override | ||||
| :meth:`~Field.get_prep_value` to convert Python objects back to query values. | ||||
|  | ||||
| For example:: | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user