在Django中获取自己的应用程序 [英] Get own applications in Django

查看:57
本文介绍了在Django中获取自己的应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法获取属于Django项目本身的应用程序列表(忽略使用 pip 安装的应用程序).

Is there a way I can get a list of the applications that belong to a Django project itself (ignoring the apps that are installed with pip).

换句话说:我可以从 settings.INSTALLED_APPS 中排除使用 pip 安装的应用吗?

Said with other words: can I exclude the apps that were installed with pip from settings.INSTALLED_APPS?

推荐答案

您可以使用 myapps 将为您提供所有自己的django应用程序.

myapps will give you all own django applications.

您可以使用

In [89]: for o in myapps:
    ...:     try:
    ...:         x = django.apps.apps.get_app_config(o)
    ...:         print x.models
    ...:     except LookupError:
    ...:         pass

这篇关于在Django中获取自己的应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆