django找不到管理命令

时间:2013-06-26 03:58:56

标签: django

我正在使用django 1.5.1并尝试移动管理命令。我有一个名为patient的应用程序,这是目录结构。

patient/
├── __init__.py
├── forms.py
├── management
│   ├── __init.py__
│   └── commands
│       ├── __init.py__
│       └── recall1.py
├── models.py
├── urls.py
├── views.py

当我尝试运行recall1命​​令时会发生以下情况:

$ python manage.py recall1
Unknown command: 'recall1'

以下是我的代码的样子:

from django.core.management.base import BaseCommand, CommandError
from recall.model import PatientRecalls, RecallType, RecallMessage
from patient.model import Patient

class Command(BaseCommand):
    args = '<patient_id patient_id ...>'

    def handle(self, *args, **options):
        for patient_id in args:
            try:
                patient = Patient.objects.get(pk=int(patient_id))
            except Patient.DoesNotExist:
                raise CommandError('Patient "%s" does not exist' % patient_id)

            patient.opened = False
            patient.save()

            self.stdout.write('Successfully closed patient "%s"' % patient_id)

在我运行这件事之前,我需要纠正什么错误?该应用程序运行良好,除了这个问题..

1 个答案:

答案 0 :(得分:4)

您的文件名__init.py____init__.pymanagement/

目录中实际上应该commands/