{{ var }}
to add variable{% ... %}
to add logic such as for loop / if clause{# ... #}
for comment{{ var | 过滤器}}
used to modify the variable here
from django.db import models
- primary key is auto generated if not provided
- logic delete v.s. physical delete
- logic delete is setting
is_delete
to True, the data is still present in the data base - physical delete means the data will be removed from the database
- logic delete is setting
- common field types
AutoField
CharField
TextField
IntegerField
DecimalField
FloatField
BooleanField
DateField
TimeField
DateTimeField
FieldField
: used for file (less common) => use object storageImageField
: used for image (less common) => use object storage
- common filed type arguments:
null = True
: can be nullblank = True
:primary_key = True
: set a field to be primary keyDateField.auto_now
: when the object was last modifiedDateField.auto_now_add
: when the object was first createdchoices
max_length
default
name|db_column
unique = True
db_index = True