在 Manus 中运行任何 Skill
一键导入
一键导入
一键在 Manus 中运行任何 Skill
开始使用django-models
星标3
分支1
更新时间2026年2月20日 18:44
Best practice for working with Django models
安装
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
SKILL.md
readonly菜单
Best practice for working with Django models
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Service layer best practices on django models
How to implement badges in html templates.
How to implement Django Spire buttons in HTML templates.
How to implement container templates in Django Spire.
How to implement tab templates in Django Spire.
How to implement table templates in Django Spire.
| name | django-models |
| description | Best practice for working with Django models |
Use the following guidelines when working in models.py files.
class InventoryBatch(HistoryModelMixin, ActivityMixin):
product = models.ForeignKey(
'product.Product',
on_delete=models.CASCADE,
related_name='batches',
related_query_name='batch'
)
location = models.ForeignKey(
'inventory_location.InventoryLocation', # note here how the patter is app_name.ModelName.
on_delete=models.CASCADE,
related_name='inventory',
related_query_name='inventory',
null=True,
blank=True
)
name = models.CharField(max_length=255)
unit_of_measure = models.CharField(
max_length=3,
choices=ProductUnitOfMeasureChoices.choices,
default=ProductUnitOfMeasureChoices.LB
)
'app_name.ModelName'.
related_name It should read like English with the related model. Typically, it is the plural version but doesn't have to be.
related_query_name is the singular version of the word.
class InventoryBatch(HistoryModelMixin, ActivityMixin):
product = models.ForeignKey(
'product.Product',
on_delete=models.CASCADE,
related_name='batches',
related_query_name='batch'
)
location = models.ForeignKey(
'inventory_location.InventoryLocation', # note here how the patter is app_name.ModelName.
on_delete=models.CASCADE,
related_name='inventory',
related_query_name='inventory',
null=True,
blank=True
)
# app/product/choices.py
from django.db.models import TextChoices
class ProductTypeChoices(TextChoices):
RAW = 'raw', 'Raw'
WORK_IN_PROGRESS = 'wip', 'Work in Progress'
FINISHED_GOOD = 'fin', 'Finished Good'
# app/product/models.py
from django.db import models
from app.product import choices
class Product(models.Model):
unit_of_measure = models.CharField(
max_length=3,
choices=choices.ProductUnitOfMeasureChoices.choices,
default=choices.ProductUnitOfMeasureChoices.LB
)