

def make_object(self, cls, fields, finalizer=None):
    obj = cls()
    for (field_name, generator) in fields.items():
        field = cls._meta.get_field(field_name)
        value = generator.next()
        if (isinstance(field, models.fields.related.ForeignKey) and isinstance(value, int)):
            field_name = ('%s_id' % e)
        if isinstance(field, models.fields.files.FileField):
            getattr(obj, field_name).save(*value, save=False)
        else:
            setattr(obj, field_name, value)
        try:
            self.stdout.write(('%s: %s; ' % (field_name, value)))
        except (UnicodeEncodeError, TypeError):
            pass
    if finalizer:
        try:
            finalizer(obj)
        except Exception as e:
            self.stdout.write(('Error finalizing Obj %s: ' % e.message))
            return False
    obj.save()
    self.stdout.write(('\nCreated new %s: ' % obj.__class__.__name__))

dataset/ETHPy150Open sbaechler/django-scaffolding/scaffolding/management/commands/scaffold.py Command.make_object/VarMisuse@88/106 `field_name`->`e`