mirror of
				https://github.com/django/django.git
				synced 2025-10-31 09:41:08 +00:00 
			
		
		
		
	[1.7.x] Fixed #23316 -- Added datetime.time serialization in migrations.
Backport of 11d9cbe2f4 from master
			
			
This commit is contained in:
		
				
					committed by
					
						 Tim Graham
						Tim Graham
					
				
			
			
				
	
			
			
			
						parent
						
							22a28dd8b0
						
					
				
				
					commit
					6e5e2b0e28
				
			
							
								
								
									
										1
									
								
								AUTHORS
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								AUTHORS
									
									
									
									
									
								
							| @@ -550,6 +550,7 @@ answer newbie questions, and generally made Django that much better: | ||||
|     Bartolome Sanchez Salado <i42sasab@uco.es> | ||||
|     Nick Sandford <nick.sandford@gmail.com> | ||||
|     Mark Sandstrom <mark@deliciouslynerdy.com> | ||||
|     Lee Sanghyuck <shlee322@elab.kr> | ||||
|     Kadesarin Sanjek | ||||
|     Tim Saylor <tim.saylor@gmail.com> | ||||
|     Massimo Scamarcia <massimo.scamarcia@gmail.com> | ||||
|   | ||||
| @@ -279,6 +279,10 @@ class MigrationWriter(object): | ||||
|             if isinstance(value, datetime_safe.date): | ||||
|                 value_repr = "datetime.%s" % value_repr | ||||
|             return value_repr, set(["import datetime"]) | ||||
|         # Times | ||||
|         elif isinstance(value, datetime.time): | ||||
|             value_repr = repr(value) | ||||
|             return value_repr, set(["import datetime"]) | ||||
|         # Settings references | ||||
|         elif isinstance(value, SettingsReference): | ||||
|             return "settings.%s" % value.setting_name, set(["from django.conf import settings"]) | ||||
|   | ||||
| @@ -524,7 +524,7 @@ Django can serialize the following: | ||||
|  | ||||
| - ``int``, ``long``, ``float``, ``bool``, ``str``, ``unicode``, ``bytes``, ``None`` | ||||
| - ``list``, ``set``, ``tuple``, ``dict`` | ||||
| - ``datetime.date`` and ``datetime.datetime`` instances | ||||
| - ``datetime.date``, ``datetime.time``, and ``datetime.datetime`` instances | ||||
| - ``decimal.Decimal`` instances | ||||
| - Any Django field | ||||
| - Any function or method reference (e.g. ``datetime.datetime.today``) | ||||
|   | ||||
| @@ -95,6 +95,7 @@ class WriterTests(TestCase): | ||||
|         self.assertSerializedEqual(datetime.datetime.today) | ||||
|         self.assertSerializedEqual(datetime.date.today()) | ||||
|         self.assertSerializedEqual(datetime.date.today) | ||||
|         self.assertSerializedEqual(datetime.datetime.now().time()) | ||||
|         with self.assertRaises(ValueError): | ||||
|             self.assertSerializedEqual(datetime.datetime(2012, 1, 1, 1, 1, tzinfo=get_default_timezone())) | ||||
|         safe_date = datetime_safe.date(2014, 3, 31) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user