mirror of
https://github.com/django/django.git
synced 2024-12-01 15:42:04 +01:00
Avoided need to import model fields in models/functions.py.
This commit is contained in:
parent
fb84e877ce
commit
fc01c84bad
@ -1,9 +1,7 @@
|
|||||||
"""
|
"""
|
||||||
Classes that represent database functions.
|
Classes that represent database functions.
|
||||||
"""
|
"""
|
||||||
from django.db.models import (
|
from django.db.models import Func, Transform, Value, fields
|
||||||
DateTimeField, Func, IntegerField, Transform, Value,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class Coalesce(Func):
|
class Coalesce(Func):
|
||||||
@ -136,7 +134,7 @@ class Length(Transform):
|
|||||||
lookup_name = 'length'
|
lookup_name = 'length'
|
||||||
|
|
||||||
def __init__(self, expression, **extra):
|
def __init__(self, expression, **extra):
|
||||||
output_field = extra.pop('output_field', IntegerField())
|
output_field = extra.pop('output_field', fields.IntegerField())
|
||||||
super(Length, self).__init__(expression, output_field=output_field, **extra)
|
super(Length, self).__init__(expression, output_field=output_field, **extra)
|
||||||
|
|
||||||
def as_mysql(self, compiler, connection):
|
def as_mysql(self, compiler, connection):
|
||||||
@ -153,7 +151,7 @@ class Now(Func):
|
|||||||
|
|
||||||
def __init__(self, output_field=None, **extra):
|
def __init__(self, output_field=None, **extra):
|
||||||
if output_field is None:
|
if output_field is None:
|
||||||
output_field = DateTimeField()
|
output_field = fields.DateTimeField()
|
||||||
super(Now, self).__init__(output_field=output_field, **extra)
|
super(Now, self).__init__(output_field=output_field, **extra)
|
||||||
|
|
||||||
def as_postgresql(self, compiler, connection):
|
def as_postgresql(self, compiler, connection):
|
||||||
|
Loading…
Reference in New Issue
Block a user