1

I am using django 1.5.1 and trying to get moving the management command. I have an app called patient and here is the directory structure.

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

Here is what happens when I try to run the recall1 command:

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

Here is how my code looks like:

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)

What wrong do I need to correct before I can run this thing? The app is running great, except for this issue..

1 Answer 1

4

Your filename __init.py__ should actually be __init__.py both in the directories management/ and commands/

Sign up to request clarification or add additional context in comments.

2 Comments

Duh. Can't believe I missed this. Thanks.
Nuts ... I have the same problem, but didn't happen to make that particular mistake :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.