mirror of
https://github.com/django/django.git
synced 2025-10-23 21:59:11 +00:00
Fixed #24837 -- field__contained_by=Range
Provide `contained_by` lookups for the equivalent single valued fields related to the range field types. This acts as the opposite direction to rangefield__contains. With thanks to schinckel for the idea and initial tests.
This commit is contained in:
@@ -60,11 +60,23 @@ if connection.vendor == 'postgresql' and connection.pg_version >= 90200:
|
||||
floats = FloatRangeField(blank=True, null=True)
|
||||
timestamps = DateTimeRangeField(blank=True, null=True)
|
||||
dates = DateRangeField(blank=True, null=True)
|
||||
|
||||
class RangeLookupsModel(PostgreSQLModel):
|
||||
parent = models.ForeignKey(RangesModel, blank=True, null=True)
|
||||
integer = models.IntegerField(blank=True, null=True)
|
||||
big_integer = models.BigIntegerField(blank=True, null=True)
|
||||
float = models.FloatField(blank=True, null=True)
|
||||
timestamp = models.DateTimeField(blank=True, null=True)
|
||||
date = models.DateField(blank=True, null=True)
|
||||
|
||||
else:
|
||||
# create an object with this name so we don't have failing imports
|
||||
class RangesModel(object):
|
||||
pass
|
||||
|
||||
class RangeLookupsModel(object):
|
||||
pass
|
||||
|
||||
|
||||
# Only create this model for postgres >= 9.4
|
||||
if connection.vendor == 'postgresql' and connection.pg_version >= 90400:
|
||||
|
||||
Reference in New Issue
Block a user