if getattr(meta, 'app_label', None) is None:
    model_module = sys.modules[new_class.__module__]
kwargs = {'app_label': model_module.__name__.split('.')[-2]}
Defining a model class in Django shell fails