import os
import re

from django.conf import settings
from django.core.management import call_command, BaseCommand


class Command(BaseCommand):
    """Load the Django project fixtures and all version fixtures"""

    def handle(self, **options):
        fixtures_dir = os.path.join(settings.DIRNAME, 'cbv', 'fixtures')
        self.stdout.write('Loading project.json')
        call_command('loaddata', 'cbv/fixtures/project.json')
        version_fixtures = [re.match(r'((?:\d+\.){2,3}json)', filename) for filename in os.listdir(fixtures_dir)]
        for match in version_fixtures:
            try:
                fixture = match.group()
            except AttributeError:
                continue
            self.stdout.write('Loading {}'.format(fixture))
            call_command('loaddata', 'cbv/fixtures/{}'.format(fixture))

import glob
import os

from django.core.management import call_command, BaseCommand


class Command(BaseCommand):
    """Load the Django project fixtures and all version fixtures"""

    def handle(self, **options):
        self.stdout.write('Loading project.json')
        call_command('loaddata', 'cbv/fixtures/project.json')
        version_fixtures = glob.glob(os.path.join('cbv', 'fixtures', '*.*.*json'))
        for fixture in version_fixtures:
            self.stdout.write('Loading {}'.format(fixture))
            call_command('loaddata', fixture)

Use glob for finding version fixtures
Use glob for finding version fixtures

Thanks @ghickman!

+ import glob
  import os
- import re
  
- from django.conf import settings
  from django.core.management import call_command, BaseCommand
  
  
  class Command(BaseCommand):
      """Load the Django project fixtures and all version fixtures"""
  
      def handle(self, **options):
-         fixtures_dir = os.path.join(settings.DIRNAME, 'cbv', 'fixtures')
          self.stdout.write('Loading project.json')
          call_command('loaddata', 'cbv/fixtures/project.json')
-         version_fixtures = [re.match(r'((?:\d+\.){2,3}json)', filename) for filename in os.listdir(fixtures_dir)]
+         version_fixtures = glob.glob(os.path.join('cbv', 'fixtures', '*.*.*json'))
-         for match in version_fixtures:
+         for fixture in version_fixtures:
-             try:
-                 fixture = match.group()
-             except AttributeError:
-                 continue
              self.stdout.write('Loading {}'.format(fixture))
-             call_command('loaddata', 'cbv/fixtures/{}'.format(fixture))
+             call_command('loaddata', fixture)
  
Use glob for finding version fixtures
## Code Before:
import os
import re

from django.conf import settings
from django.core.management import call_command, BaseCommand


class Command(BaseCommand):
    """Load the Django project fixtures and all version fixtures"""

    def handle(self, **options):
        fixtures_dir = os.path.join(settings.DIRNAME, 'cbv', 'fixtures')
        self.stdout.write('Loading project.json')
        call_command('loaddata', 'cbv/fixtures/project.json')
        version_fixtures = [re.match(r'((?:\d+\.){2,3}json)', filename) for filename in os.listdir(fixtures_dir)]
        for match in version_fixtures:
            try:
                fixture = match.group()
            except AttributeError:
                continue
            self.stdout.write('Loading {}'.format(fixture))
            call_command('loaddata', 'cbv/fixtures/{}'.format(fixture))

## Instruction:
Use glob for finding version fixtures
## Code After:
import glob
import os

from django.core.management import call_command, BaseCommand


class Command(BaseCommand):
    """Load the Django project fixtures and all version fixtures"""

    def handle(self, **options):
        self.stdout.write('Loading project.json')
        call_command('loaddata', 'cbv/fixtures/project.json')
        version_fixtures = glob.glob(os.path.join('cbv', 'fixtures', '*.*.*json'))
        for fixture in version_fixtures:
            self.stdout.write('Loading {}'.format(fixture))
            call_command('loaddata', fixture)
