[英]How do I install Mezzanine as a Django app?
I already have an existing Django website. 我已经有了一个现有的Django网站。 I have added a new url route '/blog/' where I would like to have a Mezzanine blog.
我添加了一个新的网址'/ blog /',我希望有一个Mezzanine博客。 If it possible to installed Mezzanine as an app in an existing Django site as opposed to a standalone blog application.
如果可以将Mezzanine安装为现有Django站点中的应用程序而不是独立的博客应用程序。
If you are like me, you will find that the FAQ is sorely lacking in its description of how to get Mezzanine working as an app. 如果你像我一样,你会发现常见问题解答中非常缺乏如何让Mezzanine作为应用程序工作的描述。 So here is what I did (after a painful half day of hacking) to get it integrated (somewhat):
所以这就是我所做的(在一次痛苦的半天黑客攻击之后)将其整合(有点):
cd
to the package and run the mezzanine command to create a new app ( mezzanine-project <project name>
), let's say you use the name blog
as your <project_name>
. cd
到包并运行mezzanine命令来创建一个新的应用程序( mezzanine-project <project name>
),假设您使用名称blog
作为<project_name>
。 local_settings.py
or settings.py
file, set the DATABASES
dict to use your project's database. local_settings.py
或settings.py
文件中,将DATABASES
dict设置为使用项目的数据库。 createdb
command from the mezzanine manage.py
file manage.py
文件中运行createdb
命令 Now it's time to start the hack-fest: 现在是时候开始hack-fest了:
blog
to INSTALLED_APPS
blog
添加到INSTALLED_APPS
PACKAGE_NAME_FILEBROWSER = "filebrowser_safe" PACKAGE_NAME_GRAPPELLI = "grappelli_safe" GRAPPELLI_INSTALLED = False ADMIN_REMOVAL = [] RATINGS_RANGE = range(1, 5) TESTING = False BLOG_SLUG = '' COMMENTS_UNAPPROVED_VISIBLE = True COMMENTS_REMOVED_VISIBLE = False COMMENTS_DEFAULT_APPROVED = True COMMENTS_NOTIFICATION_EMAILS = ",".join(ALL_EMAILS) COMMENT_FILTER = None
PACKAGE_NAME_FILEBROWSER = "filebrowser_safe" PACKAGE_NAME_GRAPPELLI = "grappelli_safe" GRAPPELLI_INSTALLED = False ADMIN_REMOVAL = [] RATINGS_RANGE = range(1, 5) TESTING = False BLOG_SLUG = '' COMMENTS_UNAPPROVED_VISIBLE = True COMMENTS_REMOVED_VISIBLE = False COMMENTS_DEFAULT_APPROVED = True COMMENTS_NOTIFICATION_EMAILS = ",".join(ALL_EMAILS) COMMENT_FILTER = None
.... "mezzanine.boot", "mezzanine.conf", "mezzanine.core", "mezzanine.generic", "mezzanine.blog", "mezzanine.forms", "mezzanine.pages", "mezzanine.galleries", "mezzanine.twitter", ....
.... "mezzanine.boot", "mezzanine.conf", "mezzanine.core", "mezzanine.generic", "mezzanine.blog", "mezzanine.forms", "mezzanine.pages", "mezzanine.galleries", "mezzanine.twitter", ....
mezzanine
to your TEMPLATE_DIRS
tuple os.path.join(BASE_PARENT, '<path to mezzanine>/mezzanine/mezzanine'), os.path.join(BASE_PARENT, '<path to mezzanine>/mezzanine/mezzanine/blog/templates'),
mezzanine
模板文件夹的引用添加到TEMPLATE_DIRS
元组os.path.join(BASE_PARENT, '<path to mezzanine>/mezzanine/mezzanine'), os.path.join(BASE_PARENT, '<path to mezzanine>/mezzanine/mezzanine/blog/templates'),
extends
paths in the mezzanine templates, the most obvious being in "blog_post_list.html" which just extends base.html
, instead you want it to extend the mezzanine specific base
file. extends
路径,最明显的是“blog_post_list.html”,它只是扩展了base.html
,而你希望它扩展夹层特定的base
文件。 So go to that file and replace the {% extends "base.html" %}
with {% extends "core/templates/base.html" %}
. {% extends "core/templates/base.html" %}
替换{% extends "base.html" %}
{% extends "core/templates/base.html" %}
。 This is covered in the FAQs: 这包含在常见问题解答中:
http://mezzanine.jupo.org/docs/frequently-asked-questions.html#how-can-i-add-mezzanine-to-an-existing-django-project http://mezzanine.jupo.org/docs/frequently-asked-questions.html#how-can-i-add-mezzanine-to-an-existing-django-project
TLDR: Mezzanine adds a handful of settings, apps, middleware and context processors, all defined in its default settings.py file - you just need to extract enough of those, depending on your needs. TLDR:Mezzanine添加了一些设置,应用程序,中间件和上下文处理器,都在其默认的settings.py文件中定义 - 您只需根据需要提取足够的内容。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.