
from django_extensions.management.jobs import DailyJob


class Job(DailyJob):
    help = "Django Daily Cleanup Job"

    def execute(self):
        from django.core import management
        try:
            management.call_command('clearsessions')
        except management.CommandError:
            management.call_command("cleanup")  # Django <1.5


from django_extensions.management.jobs import DailyJob


class Job(DailyJob):
    help = "Django Daily Cleanup Job"

    def execute(self):
        from django.core import management
        from django import VERSION

        if VERSION[:2] < (1, 5):
            management.call_command("cleanup")
        else:
            management.call_command("clearsessions")

Use Django's VERSION to determine which cleanup command to call
Use Django's VERSION to determine which cleanup command to call

  
  from django_extensions.management.jobs import DailyJob
  
  
  class Job(DailyJob):
      help = "Django Daily Cleanup Job"
  
      def execute(self):
          from django.core import management
+         from django import VERSION
-         try:
-             management.call_command('clearsessions')
-         except management.CommandError:
-             management.call_command("cleanup")  # Django <1.5
  
+         if VERSION[:2] < (1, 5):
+             management.call_command("cleanup")
+         else:
+             management.call_command("clearsessions")
+ 
Use Django's VERSION to determine which cleanup command to call
## Code Before:

from django_extensions.management.jobs import DailyJob


class Job(DailyJob):
    help = "Django Daily Cleanup Job"

    def execute(self):
        from django.core import management
        try:
            management.call_command('clearsessions')
        except management.CommandError:
            management.call_command("cleanup")  # Django <1.5

## Instruction:
Use Django's VERSION to determine which cleanup command to call
## Code After:

from django_extensions.management.jobs import DailyJob


class Job(DailyJob):
    help = "Django Daily Cleanup Job"

    def execute(self):
        from django.core import management
        from django import VERSION

        if VERSION[:2] < (1, 5):
            management.call_command("cleanup")
        else:
            management.call_command("clearsessions")
