mirror of
				https://github.com/django/django.git
				synced 2025-10-31 01:25:32 +00:00 
			
		
		
		
	Fixed #27473 -- Added DurationField support to Extract.
This commit is contained in:
		
				
					committed by
					
						 Tim Graham
						Tim Graham
					
				
			
			
				
	
			
			
			
						parent
						
							63e9a71ec4
						
					
				
				
					commit
					43a4835edf
				
			| @@ -331,12 +331,16 @@ We'll be using the following model in examples of each function:: | ||||
|  | ||||
| Extracts a component of a date as a number. | ||||
|  | ||||
| Takes an ``expression`` representing a ``DateField`` or ``DateTimeField`` and a | ||||
| ``lookup_name``, and returns the part of the date referenced by ``lookup_name`` | ||||
| as an ``IntegerField``. Django usually uses the databases' extract function, so | ||||
| you may use any ``lookup_name`` that your database supports. A ``tzinfo`` | ||||
| subclass, usually provided by ``pytz``, can be passed to extract a value in a | ||||
| specific timezone. | ||||
| Takes an ``expression`` representing a ``DateField``, ``DateTimeField``, | ||||
| ``TimeField``, or ``DurationField`` and a ``lookup_name``, and returns the part | ||||
| of the date referenced by ``lookup_name`` as an ``IntegerField``. | ||||
| Django usually uses the databases' extract function, so you may use any | ||||
| ``lookup_name`` that your database supports. A ``tzinfo`` subclass, usually | ||||
| provided by ``pytz``, can be passed to extract a value in a specific timezone. | ||||
|  | ||||
| .. versionchanged:: 2.0 | ||||
|  | ||||
|     Support for ``DurationField`` was added. | ||||
|  | ||||
| Given the datetime ``2015-06-15 23:30:01.000321+00:00``, the built-in | ||||
| ``lookup_name``\s return: | ||||
|   | ||||
| @@ -248,6 +248,10 @@ Models | ||||
| * Added the :attr:`~django.db.models.Index.db_tablespace` parameter to | ||||
|   class-based indexes. | ||||
|  | ||||
| * If the database supports a native duration field (Oracle and PostgreSQL), | ||||
|   :class:`~django.db.models.functions.datetime.Extract` now works with | ||||
|   :class:`~django.db.models.DurationField`. | ||||
|  | ||||
| Requests and Responses | ||||
| ~~~~~~~~~~~~~~~~~~~~~~ | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user