访问 Django 管理界面中的各种模式?

发布于 2024-09-24 04:40:30 字数 726 浏览 3 评论 0原文

我正在使用mysql数据库。我有很多模式和很多表。我想为不同模式中的各种表创建一个 Django 管理界面。目前,对于单个架构,我使用如下设置:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'schema1',                      
        'USER': 'test',                     
        'PASSWORD': 'test',                  
        'HOST': 'example.abc.com',                     
        'PORT': '',                      
    }

创建应用程序后,将为我在该架构的该应用程序的 admin.py 中注册的任何模型创建管理界面。现在我想创建另一个应用程序,在其 admin.py 中注册另一个架构的模型。这些模型将属于不同的模式。现在,如何为指向不同架构的第二个应用程序创建管理界面?

是否可以创建两个具有两个不同的 settings.py 和两个不同的管理界面的 Django 项目? (这样每个人都会指向不同的模式。)

我已经在谷歌上搜索了很多关于这个的内容。但找不到任何信息。可能有一个简单的方法,但我正在以错误的方式处理这个问题。任何帮助表示赞赏。

提前致谢。

I am using mysql database. I have many schemas with many tables. I want to create a Django admin interface for various tables in different schemas. Currently for a single schema I am using a setting like this:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'schema1',                      
        'USER': 'test',                     
        'PASSWORD': 'test',                  
        'HOST': 'example.abc.com',                     
        'PORT': '',                      
    }

After creating an app, admin interface is created for whatever models I register in the admin.py of that app for this schema. Now I want to create an other app where I register models of another schema in its admin.py. These models will belong to different schema. Now how do I create an admin interface for the second app that points to different schema?

Is it possible to create two Django projects with two different settings.py and two different admin interfaces? (So that each will point to different schema.)

I have googled a lot about this. But couldn't find any info. May be there is a simple way and I am approaching this in a wrong way. Any help is appreciated.

Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

゛时过境迁 2024-10-01 04:40:30

我不太确定您的意思是要处理不同的数据库还是只是注册不同的模型。如果你想在不同的管理站点中有不同的模型,你可以 使用不同的模型注册多个管理站点。然后,您可以使用“/admin”访问一个站点,使用“/otheradmin”访问另一个站点。也许您发现 django-admin-tools 对于自定义显示很有用您的模型/应用程序在管理员中!

I'm not quite sure if you mean that you want to handle different databases or just have different models registered. If you want to have different models in different admin sites, you can register multiple admin sites with different models. You can then access one site eg with '/admin' the other with '/otheradmin'. Maybe you find django-admin-tools useful to customize the display of your models/apps within the admin!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文