Model django
Estimated reading time: 1 minutedjango.db.models.Model
database fields
auto generates with api
class ModelName(**kwargs):
# rest
register models
INSTALLED_APPS = [
#...
'myapp',
#...
]
command
manage.py makemigrations
manage.py migrate
fields
options
null
blank
default
unique
verbose_name
primary_key
help_text
choices
~
db_column
db_index
db_tablespace
editable
error_message
validator
types
AutoField
BigAutoField
BigIntegerField
BinaryField
BooleanField
CharField
DateField
DateTimeField
DecimalField
DurationField
EmailField
FileField
FileField and FieldFile
FilePathField
FloatField
ImageField
IntegerField
GenericIPAddressField
NullBooleanField
PositiveIntegerField
PositiveSmallIntegerField
SlugField
SmallIntegerField
TextField
TimeField
URLField
UUIDField
relational
ForeignKey
ManyToManyField
OneToOneField
~ fields