2013-06-26 80 views
1

我正在使用django 1.5.1并试图移动管理命令。我有一个名为耐心的应用程序,这里是目录结构。django找不到管理命令

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) 

自己做错了什么,我需要纠正前我可以运行这个东西?除了此问题的应用程序正在运行伟大..

回答

3

你的文件名__init.py__实际上应该是__init__.py无论是在目录management/commands/

+0

咄。不能相信我错过了这一点。谢谢。 – Trewq

+0

坚果...我有同样的问题,但没有发生这种特殊的错误:) – offby1