Make generateimages support pre Django 1.8 versions

This commit is contained in:
Yuri Kanivetsky 2017-09-12 20:44:22 +03:00
parent a153812add
commit de3047e73d

View file

@ -12,6 +12,7 @@ segments. (Segments are separated with colons.) So, for example,
"a:*:c" will match "a:b:c", but not "a:b:x:c", whereas "a:**:c" will
match both. Subsegments are always matched, so "a" will match "a" as
well as "a:b" and "a:b:c".""")
args = '[generator_ids]'
def add_arguments(self, parser):
parser.add_argument('generator_id', nargs='*', help='<app_name>:<model>:<field> for model specs')
@ -19,8 +20,9 @@ well as "a:b" and "a:b:c".""")
def handle(self, *args, **options):
generators = generator_registry.get_ids()
if options['generator_id']:
patterns = self.compile_patterns(options['generator_id'])
generator_ids = options['generator_id'] if 'generator_id' in options else args
if generator_ids:
patterns = self.compile_patterns(generator_ids)
generators = (id for id in generators if any(p.match(id) for p in patterns))
for generator_id in generators: