简体   繁体   English

Django:具有多种网站和语言的管理员

[英]Django: Admin with multiple sites & languages

I'm supposed to build some Django apps, that allow you to administer multiple sites through one backend. 我应该构建一些Django应用,使您可以通过一个后端管理多个站点。 The contrib.sites framework is quite perfect for my purposes. 对于我的目的, contrib.sites框架非常完美。 I can run multiple instances of manage.py with different settings for each site; 我可以为每个站点运行具有不同设置的manage.py多个实例; but how should django's admin deal with different settings for different sites, eg. 但是django的管理员应该如何处理不同网站的不同设置,例如 if they have different sets of languages, a different (default) language? 如果他们使用不同的语言集,则使用不同的(默认)语言? So there are some problem s to face if you have to work on objects coming from different sites in one admin... 因此,如果您必须在一个管理员中处理来自不同站点的对象,则会面临一些问题。

I think settings.ADMIN_FOR is supposed to be quite helpful for cases like this, but theres hardly any documentation about it and I think it's not really used in the actual Django version (?). 我认为settings.ADMIN_FOR在这种情况下应该会非常有用,但是几乎没有任何文档,而且我认为在实际的Django版本中并没有真正使用它(?)。

So any ideas/solutions are welcome and much appreciated! 因此,欢迎任何想法/解决方案,并深表感谢! Thanks a lot... 非常感谢...

There is an old blog post by James Bennet which might be helpful: James Bennet有一篇旧的博客文章可能会有所帮助:

  1. Create a new Site object in your admin for each domain, and put the id of that Site into its settings file as SITE_ID so Django knows which site in the database corresponds to this settings file. 在管理员中为每个域创建一个新的Site对象,并将该Site的ID作为SITE_ID放入其设置文件中,以便Django知道数据库中的哪个站点与此设置文件相对应。
  2. In the settings file for your original site (the one with id 1), add the other sites' settings files to the ADMIN_FOR setting, to let Django know that this one instance of the admin application will handle all of the sites. 在原始站点的设置文件(ID为1的站点)中,将其他站点的设置文件添加到ADMIN_FOR设置中,以使Django知道管理应用程序的这一实例将处理所有站点。

As documented ADMIN_FOR (for which i can not post link) should be a tuple of settings modules much like INSTALED_APPS is a tuple of django app modules. 正如所记录的,ADMIN_FOR(我无法发布链接)应该是设置模块的元组,就像INSTALED_APPS是django应用程序模块的元组一样。

Note that blog post is from 2006 so it uses a bit outdated API. 请注意,博客文章来自2006年,因此它使用了一些过时的API。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM