db.models.Lookup

class Lookup [source] A Lookup is a generic class to implement lookups. A lookup is a query expression with a left-hand side, lhs; a right-hand side, rhs; and a lookup_name that is used to produce a boolean comparison between lhs and rhs such as lhs in rhs or lhs > rhs. The notation to use a lookup in an expression is <lhs>__<lookup_name>=<rhs>. This class doesn’t follow the Query Expression API since it has =<rhs> on its construction: lookups are always the end of

db.models.ImageField

class ImageField(upload_to=None, height_field=None, width_field=None, max_length=100, **options) [source] Inherits all attributes and methods from FileField, but also validates that the uploaded object is a valid image. In addition to the special attributes that are available for FileField, an ImageField also has height and width attributes. To facilitate querying on those attributes, ImageField has two extra optional arguments:

db.models.get_lookup()

get_lookup(lookup_name) Must return the lookup named lookup_name. For instance, by returning self.output_field.get_lookup(lookup_name).

db.models.get_transform()

get_transform(transform_name) Must return the lookup named transform_name. For instance, by returning self.output_field.get_transform(transform_name).

db.models.GenericIPAddressField.unpack_ipv4

GenericIPAddressField.unpack_ipv4 Unpacks IPv4 mapped addresses like ::ffff:192.0.2.1. If this option is enabled that address would be unpacked to 192.0.2.1. Default is disabled. Can only be used when protocol is set to 'both'. If you allow for blank values, you have to allow for null values since blank values are stored as null.

db.models.ImageField.height_field

ImageField.height_field Name of a model field which will be auto-populated with the height of the image each time the model instance is saved.

db.models.GenericIPAddressField.protocol

GenericIPAddressField.protocol Limits valid inputs to the specified protocol. Accepted values are 'both' (default), 'IPv4' or 'IPv6'. Matching is case insensitive.

db.models.functions.Upper

class Upper(expression, **extra) [source] Accepts a single text field or expression and returns the uppercase representation. It can also be registered as a transform as described in Length. Usage example: >>> from django.db.models.functions import Upper >>> Author.objects.create(name='Margaret Smith') >>> author = Author.objects.annotate(name_upper=Upper('name')).get() >>> print(author.name_upper) MARGARET SMITH Changed in Django 1.9: The ability to reg

db.models.functions.Substr

class Substr(expression, pos, length=None, **extra) [source] Returns a substring of length length from the field or expression starting at position pos. The position is 1-indexed, so the position must be greater than 0. If length is None, then the rest of the string will be returned. Usage example: >>> # Set the alias to the first 5 characters of the name as lowercase >>> from django.db.models.functions import Substr, Lower >>> Author.objects.create(name='Margaret

db.models.GenericIPAddressField

class GenericIPAddressField(protocol='both', unpack_ipv4=False, **options) [source] An IPv4 or IPv6 address, in string format (e.g. 192.0.2.30 or 2a02:42fe::4). The default form widget for this field is a TextInput. The IPv6 address normalization follows RFC 4291#section-2.2 section 2.2, including using the IPv4 format suggested in paragraph 3 of that section, like ::ffff:192.0.2.0. For example, 2001:0::0:01 would be normalized to 2001::1, and ::ffff:0a0a:0a0a to ::ffff:10.10.10.10. All char