界面已本地化;技能介绍与说明文档按所选语言由 AI 自动翻译,代码、命令、路径和专业术语保留原文,以原作者文档为准。
探索技能
效率与协作 · SKILL.md

django-integration

django-integration

【效率与协作】Use ChatterBot Django app integration, DjangoStorageAdapter, CHATTERBOT settings, migrations, swappable models, admin, views, and example project workflows.

独立 GitHub 快照 · 自动分类 · 以原作者文档为准

技能说明

GitHub

name: django-integration description: "Use ChatterBot Django app integration, DjangoStorageAdapter, CHATTERBOT settings, migrations, swappable models, admin, views, and example project workflows." disable-model-invocation: true metadata: disco-role: operating license: BSD 3-Clause

Django Integration

Use this sub-skill when a task asks how to add ChatterBot to a Django project, configure chatterbot.ext.django_chatterbot, run migrations, use DjangoStorageAdapter, customize statement/tag models, debug Django settings, or adapt the ChatterBot Django example app.

Quick route

  1. Read references/django-api.md for adapter, settings, models, and migration facts.
  2. Read references/workflows.md for project setup, minimal settings, custom models, view/API wiring, and example app smoke checks.
  3. Read references/troubleshooting.md for ImproperlyConfigured, missing apps, migrations, database aliases, and swappable model issues.
  4. Run scripts/django_config_smoke.py for a safe in-memory Django configuration check.

Required setup

A Django project must install both Django and ChatterBot:

python -m pip install django chatterbot

Add the app:

INSTALLED_APPS = [
    # ...
    "chatterbot.ext.django_chatterbot",
]

Run migrations:

python manage.py migrate django_chatterbot

Then create a bot with Django storage:

from chatterbot import ChatBot

bot = ChatBot(
    "Django Bot",
    storage_adapter="chatterbot.storage.DjangoStorageAdapter",
)

ChatterBot Django settings

The extension provides default settings in chatterbot.ext.django_chatterbot.settings:

CHATTERBOT = {
    "name": "ChatterBot",
    "storage_adapter": "chatterbot.storage.DjangoStorageAdapter",
    "django_app_name": "django_chatterbot",
}

In project settings, override CHATTERBOT as needed, but keep the Django storage adapter when using Django ORM tables.

Swappable models

The default models are swappable:

  • CHATTERBOT_STATEMENT_MODEL
  • CHATTERBOT_TAG_MODEL

Use custom models only when you understand Django swappable model migration rules. For ordinary projects, prefer the default Statement and Tag models.

Boundaries

我的收藏