django.apps.get_model

Here are the examples of the python api django.apps.get_model taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

2 Examples 7

Example 1

Project: ava Source File: utils.py
def log_gather_history(model_name, message, no_people, no_groups, no_identifiers, status=GatherHistory.COMPLETED):
    history = apps.get_model(model_name)

    store, created = history.objects.create(message=message, no_groups=no_groups, no_people=no_people,
                                            no_identifiers=no_identifiers, import_status=status)
    store.save()

Example 2

Project: btb Source File: __init__.py
def set_up_groups(apps=None, schema_editor=None, with_create_permissions=True):
    # Branch to work either in a migration, or in a test loader.
    if apps:
        ContentType = apps.get_model('contenttypes', 'ContentType')
    else:
        from django import apps
        from django.contrib.contenttypes.models import ContentType

    # Ensure ``makepermissions`` has run.  Ugly hack:
    # https://code.djangoproject.com/ticket/23422
    if ContentType.objects.count() == 0 and with_create_permissions:
        from django.contrib.auth.management import create_permissions
        assert not hasattr(apps, 'models_module')
        apps.models_module = True
        create_permissions(apps, verbosity=0)
        del apps.models_module
        return set_up_groups(apps, schema_editor, with_create_permissions=False)

    call_command("loaddata", "btb/fixtures/groups.json",
            interactive=False, verbosity=0)