首页 > 代码库 > #module-django.db.models
#module-django.db.models
Models
A model is the single, definitive source of information about your data. It contains the essential fields and behaviors of the data you‘re storing. Generally, each model maps to a single database table.
The basics:
- Each model is a Python class that subclasses?django.db.models.Model.
- Each attribute of the model represents a database field.
- With all of this, Django gives you an automatically-generated database-access API; see?Making queries.
?
Quick example
Using models
Fields
Field types
Field options
null
blank
choices
default
help_text
primary_key
unique
Automatic primary key fields
Verbose field names
Relationships
Many-to-one relationships
Many-to-many relationships
Extra fields on many-to-many relationships
One-to-one relationships
Models across files
Field name restrictions
Custom field types
Meta options
Model methods
Overriding predefined model methods
Overriding predefined model methods
Executing custom SQL
Model inheritance
Abstract base classes
Meta?inheritance
Be careful with?related_name
Multi-table inheritance
Meta?and multi-table inheritance
Proxy models
Base class restrictions
Multiple inheritance
Field name "hiding" is not permitted
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。