django找不到管理命令
我正在使用django 1.5.1并尝试移动管理命令。我有一个名为patient的应用程序,下面是目录结构django找不到管理命令,django,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命令时发
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)
来自django.core.management.base import BaseCommand的,CommandError
从recall.model导入PatientCalls、RecallType、RecallMessage
从患者。模型导入患者
类命令(BaseCommand):
args=''
def句柄(自身、*参数、**选项):
对于参数中的患者id:
尝试:
patient=patient.objects.get(pk=int(patient_id))
除病人外,医生:
raise CommandError('患者“%s”不存在“%Patient\u id”)
patient.opened=False
病人,救命
self.stdout.write('已成功关闭患者“%s”%patient\u id)
在运行此程序之前,我需要纠正什么错误?应用程序运行得很好,除了这个问题。你的文件名
\uuu init.py\uuuu
实际上应该是\uuu init\uuuuuu.py
目录management/
和命令/
你的文件名\uu init.py\uu
实际上应该是\uu init.py
和目录中的.py命令/
Duh。真不敢相信我错过了这个。谢谢,胡说八道。。。我也有同样的问题,但没有碰巧犯那个特别的错误:)嗯。真不敢相信我错过了这个。谢谢,胡说八道。。。我也有同样的问题,但并没有碰巧犯那个特别的错误:)