访问Django管理界面中的各种模式? [英] accessing various schemas in Django admin interface?

查看:175
本文介绍了访问Django管理界面中的各种模式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

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



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



我已经很多关于这个了。但找不到任何信息。可能有一个简单的方法,我以错误的方式接近这个。任何帮助都不胜感激。



提前感谢

解决方案

如果您的意思是要处理不同的数据库,或者只注册不同的型号,那么我不太确定。如果你想在不同的管理网站上有不同的模型,你可以注册具有不同型号的多个管理站点。然后,您可以访问一个站点,例如使用'/ admin'另一个与'/ otheradmin'。也许您会发现 django-admin-tools 可用于自定义显示的您的模型/管理员中的应用程序!


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.

解决方案

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!

这篇关于访问Django管理界面中的各种模式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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