Field Types
AutoField |
BigIntegerField |
BinaryField |
BooleanField |
CharField |
max_length |
CommaSeparatedIntegerField |
max_length |
DateField |
auto_now |
|
auto_now_add |
DateTimeField |
(as above) |
DecimalField |
max_digits |
|
decimal_places |
EmailField |
max_length |
FileField |
upload_to |
|
storage |
FloatField |
ImageField |
upload_to |
|
height_field |
|
width_field |
IntegerField |
IPAddressField |
GenericIPAddressField |
protocol |
|
unpack_ipv4 |
NullBooleanField |
PositiveIntegerField |
PositiveSmallIntegerField |
SlugField |
max_length |
SmallIntegerField |
TextField |
TimeField |
auto_now |
|
auto_now_add |
URLField |
max_length |
ForeignKey |
model |
|
related_name |
|
to_field |
|
db_constraint (True) |
|
on_delete |
ManyToManyField |
model |
|
limit_choices_to |
OneToOneField |
|
|
Field Options
null |
blank |
choices |
db_column |
db_index |
db_tablespace |
default |
editable |
error_messages |
help_text |
primary_key |
unique |
unique_for_[date|month|year] |
verbose_name |
validators |
Field Lookups
__exact |
__iexact |
Case Insensitive |
__contains |
__icontains |
__in |
Pass in a list |
__gt, __gte, __lt, __lte |
Comparison |
__startswith, __istartswith, __endswith, __iendswith |
__range |
(inclusive) =(X, Y) |
__year, __month, __day, __hour, __minute, __second |
__week_day |
1=Sun, 7=Sat |
__isnull |
__regex |
Related Manager Methods
add |
x.ys_set.add(y, ...) |
create |
x.ys_set.create(**kwargs) |
remove* |
x.ys_set.remove(y1, y2, ...) |
clear* |
x.ys_set.clear() |
|
*Only available when FK(null=True) |
|
|
QuerySet API
all |
X.objects. |
filter |
filter(**kwargs) |
exclude |
exclude(**kwargs) |
annotate |
annotate( models.Count('cost') ) |
order_by |
[*fields_str] |
reverse |
distinct |
values |
*fields_str |
values_list |
*fields_str |
date(time)?s |
dates(field, kind, order) |
none |
extra |
extra(select={}) |
get (returns 1 obj) |
get( **kwargs ) |
create (returns 1 obj) |
create( **kwargs ) |
get_or_create (returns 1 obj) |
get_or_create( **kwargs ) |
count |
latest, earliest, first, last |
aggregate |
aggregate( models.Count('entry') ) |
delete |
Meta Options
abstract |
app_label |
db_table |
db_tablespace |
get_latest_by |
managed |
order_with_respect_to |
ordering |
permissions |
proxy |
unique_together |
index_together |
verbose_name |
verbose_name_plural |
|
Created By
lewiseason.co.uk
Metadata
Favourited By
Comments
No comments yet. Add yours below!
Add a Comment
Related Cheat Sheets