Custom django-admin command issue in Python Programming Language?



Report

1 Answer(s) available

13 


Your indentation needs to be consistent through the entire file, which it isn't in the snippet you posted above.

The "help = " line is indented four spaces after "class" but then the "x =" line is indented many more than four.

Maybe you are mixing spaces and tabs and thus have two tabs before "x ="?

Your code should look like this:

from django.core.management.base import BaseCommand
from mailing.msystem.models import Alarm

class Command(BaseCommand):
    help = "Displays data"
    def handle(self, *args, **options):
        x = Alarm.objects.all()
        for i in x:
            print i.name


Report

Related Questions