0

I created a simple django command and when I want to test it from the command line (terminal) I get a NotImplementedError.

My code:

from django.db import models
from django.core.management.base import NoArgsCommand
from email.mime.text import MIMEText

import logging
from datetime import date, timedelta

logger = logging.getLogger('dataimport')


class Command(NoArgsCommand):

    def handele_noargs(self, **options):
        # Sending all the errors
        logger.info("test")

The error I get:

Traceback (most recent call last):

File "manage.py", line 11, in execute_manager(settings)

File "/.../python2.7/site-packages/django/core/management/init.py", line 459, in execute_manager utility.execute()

File "/.../python2.7/site-packages/django/core/management/init.py", line 382, in execute self.fetch_command(subcommand).run_from_argv(self.argv)

File "/.../python2.7/site-packages/django/core/management/base.py", line 196, in run_from_argv self.execute(*args, **options.dict)

File "/.../python2.7/site-packages/django/core/management/base.py", line 232, in execute output = self.handle(*args, **options)

File "/.../python2.7/site-packages/django/core/management/base.py", line 371, in handle return self.handle_noargs(**options)

File "/.../python2.7/site-packages/django/core/management/base.py", line 378, in handle_noargs raise NotImplementedError()

NotImplementedError

Frederik Voordeckers
  • 1,321
  • 15
  • 31

1 Answers1

3

You made a typo:

def handele_noargs(self, **options):

should be:

def handle_noargs(self, **options):

One could only dream of having Java @Override annotation in Python. Or one could write it: https://stackoverflow.com/a/8313042/1240162

Community
  • 1
  • 1
Nigel Tufnel
  • 11,146
  • 4
  • 35
  • 31