Get a list of models for the given app labels, with some exceptions.
    TODO: If a required model is referenced, it should also be included.
    Or at least discovered with a get_or_create() call.
489074
def get_models(app_labels):
    

    # These models are not to be output, e.g. because they can be generated automatically
    # TODO: This should be "appname.modelname" string
    EXCLUDED_MODELS = (ContentType, )

    models = []

    # If no app labels are given, return all
    if not app_labels:
        for app in apps.get_app_configs():
            models += [m for m in apps.get_app_config(app.label).get_models()
                       if m not in EXCLUDED_MODELS]
        return models

    # Get all relevant apps
    for app_label in app_labels:
        # If a specific model is mentioned, get only that model
        if "." in app_label:
            app_label, model_name = app_label.split(".", 1)
            models.append(apps.get_model(app_label, model_name))
        # Get all models for a given app
        else:
            models += [m for m in apps.get_app_config(app_label).get_models()
                       if m not in EXCLUDED_MODELS]

    return models
381332
def get_models(self):
        
        try:
            rels = self.rels_ext.content
        except RequestFailed:
            # if rels-ext can't be retrieved, confirm this object does not have a RELS-EXT
            # (in which case, it does not have any content models)
            if "RELS-EXT" not in self.ds_list.keys():
                return []
            else:
                raise

        return list(rels.objects(self.uriref, modelns.hasModel))
379017
def get_apphook_field_names(model):
    
    key = APP_CONFIG_FIELDS_KEY.format(
        app_label=model._meta.app_label,
        model_name=model._meta.object_name
    ).lower()
    if not hasattr(model, key):
        field_names = _get_apphook_field_names(model)
        setattr(model, key, field_names)
    return getattr(model, key)
467865
def get_urls(self):
        
        info = '%s_%s' % (self.model._meta.app_label, self.model._meta.model_name)

        def pat(regex, fn):
            return url(regex, self.admin_site.admin_view(fn), name='%s_%s' % (info, fn.__name__))

        url_patterns = [
            pat(r'^([0-9]+)/delete-translation/$', self.delete_translation),
            pat(r'^([0-9]+)/([a-z\-]+)/publish/$', self.publish_article),
            pat(r'^([0-9]+)/([a-z\-]+)/unpublish/$', self.unpublish),
            pat(r'^([0-9]+)/([a-z\-]+)/preview/$', self.preview_article),
        ]

        url_patterns += super(ArticleAdmin, self).get_urls()
        return url_patterns
399593
def get_download_urls(self):
        
        info = self.model._meta.app_label, self.model._meta.model_name
        return [
            url(r'^.+(' + self.upload_to + '/.+)/$', self.file_download_view, name='%s_%s_file_download' % info),
        ]
410083
def get_model_choices():
    
    result = []
    for ct in ContentType.objects.order_by('app_label', 'model'):
        try:
            if issubclass(ct.model_class(), TranslatableModel):
                result.append(
                    ('{} - {}'.format(ct.app_label, ct.model.lower()),
                     '{} - {}'.format(ct.app_label.capitalize(), ct.model_class()._meta.verbose_name_plural))
                )
        except TypeError:
            continue
    return result
740396
def get_label(self, queryset, query_data):
        
        if query_data.get('label', False):
            return query_data['label']

        try:
            return queryset.model.__name__
        except AttributeError:
            return query_data['queryset'].model.__name__
118970
def _get_model_name(self, modeldata):
        
        if 'change_url' in modeldata:
            return modeldata['change_url'].strip('/').split('/')[-1]   # /foo/admin/appname/modelname
        elif 'add_url' in modeldata:
            return modeldata['add_url'].strip('/').split('/')[-2]      # /foo/admin/appname/modelname/add
        else:
            raise ValueError("Missing attributes in modeldata to find the model name!")
657659
def get_profile_model():
    
    user_profile_module = getattr(settings, 'USER_PROFILE_MODULE', None)
    if user_profile_module:
        app_label, model_name = user_profile_module.split('.')
        return get_model(app_label, model_name)
    else:
        return None
1218000
def get_premises_model():
    
    try:
        app_label, model_name = PREMISES_MODEL.split('.')
    except ValueError:
        raise ImproperlyConfigured("OPENINGHOURS_PREMISES_MODEL must be of the"
                                   " form 'app_label.model_name'")
    premises_model = get_model(app_label=app_label, model_name=model_name)
    if premises_model is None:
        raise ImproperlyConfigured("OPENINGHOURS_PREMISES_MODEL refers to"
                                   " model '%s' that has not been installed"
                                   % PREMISES_MODEL)
    return premises_model
1236255
def crud_for_app(app_label, urlprefix=None):
    
    if urlprefix is None:
        urlprefix = app_label + '/'
    app = apps.get_app_config(app_label)
    urls = []
    for model in app.get_models():
        urls += crud_for_model(model, urlprefix)
    return urls
517283
def get_content_models(self):
        
        models = super(PageAdmin, self).get_content_models()

        order = [name.lower() for name in settings.ADD_PAGE_ORDER]

        def sort_key(page):
            name = "%s.%s" % (page._meta.app_label, page._meta.object_name)
            unordered = len(order)
            try:
                return (order.index(name.lower()), "")
            except ValueError:
                return (unordered, page.meta_verbose_name)
        return sorted(models, key=sort_key)
997349
def get_supported_app_labels(self):
        
        get_app_label = lambda x: x.split(".", 1)[0]
        if not hasattr(self, '_app_labels_cache'):
            perms = self.get_supported_permissions()
            self._app_labels_cache = set([get_app_label(x) for x in perms])
        return self._app_labels_cache
851418
def labels(self):
        
        if self._labels is None:
            self._labels = self.instance.labels
        return self._labels
649191
def get_model(model):
    
    try:
        if isinstance(model, str):
            app_label, model_name = model.split('.', 1)
            m = loading.get_model(app_label, model_name)
            if not m:  # pragma: no cover
                raise LookupError()  # Django < 1.7 just returns None
            return m
        elif issubclass(model, models.Model):
            return model
    except (LookupError, ValueError):
        pass
    raise ValueError(model)
799180
def get_labels(obj):
        
        if Clustering.is_pyclustering_instance(obj.model):
            return obj._labels_from_pyclusters
        else:
            return obj.model.labels_
830217
def get_index_models(index):
    
    models = []
    for app_model in get_index_config(index).get("models"):
        app, model = app_model.split(".")
        models.append(apps.get_model(app, model))
    return models