如何将Mezzanine安装为Django应用程序?

时间:2023-01-12 18:38:08

I already have an existing Django website. I have added a new url route '/blog/' where I would like to have a Mezzanine blog. If it possible to installed Mezzanine as an app in an existing Django site as opposed to a standalone blog application.

我已经有了一个现有的Django网站。我添加了一个新的网址'/ blog /',我希望有一个Mezzanine博客。如果可以将Mezzanine安装为现有Django站点中的应用程序而不是独立的博客应用程序。

2 个解决方案

#1


11  

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. So here is what I did (after a painful half day of hacking) to get it integrated (somewhat):

如果你像我一样,你会发现常见问题解答中非常缺乏如何让Mezzanine作为应用程序运行的描述。所以这就是我所做的(在经历了痛苦的半天黑客攻击之后)将其整合(有点):

  1. Download the repo and copy it into your project
  2. 下载回购并将其复制到您的项目中
  3. Run setup.py for the package
  4. 运行包的setup.py
  5. 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>.
  6. cd到包并运行mezzanine命令来创建一个新的应用程序(mezzanine-project <项目名称> ),假设您使用名称blog作为
  7. In either the local_settings.py or settings.py file, set the DATABASES dict to use your project's database.
  8. 在local_settings.py或settings.py文件中,将DATABASES dict设置为使用项目的数据库。
  9. Run the createdb command from the mezzanine manage.py file
  10. 从夹层管理.py文件中运行createdb命令

Now it's time to start the hack-fest:

现在是时候开始hack-fest了:

  1. In your project's settings.py file, add blog to INSTALLED_APPS
  2. 在项目的settings.py文件中,将博客添加到INSTALLED_APPS
  3. Add some configuration variables to settings.py that Mezzanine is expecting: 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
  4. 添加一些配置变量的settings.py该夹层期待:PACKAGE_NAME_FILEBROWSER = “filebrowser_safe” PACKAGE_NAME_GRAPPELLI = “grappelli_safe” GRAPPELLI_INSTALLED =假ADMIN_REMOVAL = [] RATINGS_RANGE =范围(1,5)测试=假BLOG_SLUG = '' COMMENTS_UNAPPROVED_VISIBLE =真COMMENTS_REMOVED_VISIBLE = FAME COMMENTS_DEFAULT_APPROVED = True COMMENTS_NOTIFICATION_EMAILS =“,”。join(ALL_EMAILS)COMMENT_FILTER = None
  5. Add some middleware that Mezzanine is expecting: ```` ... "mezzanine.core.request.CurrentRequestMiddleware", "mezzanine.core.middleware.RedirectFallbackMiddleware", "mezzanine.core.middleware.TemplateForDeviceMiddleware", "mezzanine.core.middleware.TemplateForHostMiddleware", "mezzanine.core.middleware.AdminLoginInterfaceSelectorMiddleware", "mezzanine.core.middleware.SitePermissionMiddleware",

    Uncomment the following if using any of the SSL settings:

    "mezzanine.core.middleware.SSLRedirectMiddleware",

    "mezzanine.pages.middleware.PageMiddleware", .... ````
  6. 添加Mezzanine期待的一些中间件:````mezzanine.core.request.CurrentRequestMiddleware“,”mezzanine.core.middleware.RedirectFallbackMiddleware“,”mezzanine.core.middleware.TemplateForDeviceMiddleware“,”mezzanine.core。 middleware.TemplateForHostMiddleware“,”mezzanine.core.middleware.AdminLoginInterfaceSelectorMiddleware“,”mezzanine.core.middleware.SitePermissionMiddleware“,如果使用任何SSL设置,请取消注释以下内容:”mezzanine.core.middleware.SSLRedirectMiddleware“,”mezzanine.pages .middleware.PageMiddleware“,....````
  7. Add some INSTALLED_APPS that Mezzanine is expecting: .... "mezzanine.boot", "mezzanine.conf", "mezzanine.core", "mezzanine.generic", "mezzanine.blog", "mezzanine.forms", "mezzanine.pages", "mezzanine.galleries", "mezzanine.twitter", ....
  8. 添加一些Mezzanine期待的INSTALLED_APPS:....“mezzanine.boot”,“mezzanine.conf”,“mezzanine.core”,“mezzanine.generic”,“mezzanine.blog”,“mezzanine.forms”,“夹层楼” .pages“,”mezzanine.galleries“,”mezzanine.twitter“,....
  9. Add references to the template folders of 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'),
  10. 将夹层的模板文件夹的引用添加到TEMPLATE_DIRS元组os.path.join(BASE_PARENT,' <夹层到 mezzanine mezzanine'的路径),os.path.join(base_parent,'<夹层路径> / mezzanine /夹层/博客/模板),
  11. Finally, if your like me, you'll have to override some of the 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. So go to that file and replace the {% extends "base.html" %} with {% extends "core/templates/base.html" %}.
  12. 最后,如果你喜欢我,你将不得不覆盖夹层模板中的一些扩展路径,最明显的是“blog_post_list.html”,它只是扩展了base.html,而你希望它扩展夹层特定的基础文件。所以转到该文件并用{%extends“core / templates / base.html”%}替换{%extends“base.html”%}。

#2


4  

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文件中定义 - 您只需根据需要提取足够的内容。

#1


11  

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. So here is what I did (after a painful half day of hacking) to get it integrated (somewhat):

如果你像我一样,你会发现常见问题解答中非常缺乏如何让Mezzanine作为应用程序运行的描述。所以这就是我所做的(在经历了痛苦的半天黑客攻击之后)将其整合(有点):

  1. Download the repo and copy it into your project
  2. 下载回购并将其复制到您的项目中
  3. Run setup.py for the package
  4. 运行包的setup.py
  5. 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>.
  6. cd到包并运行mezzanine命令来创建一个新的应用程序(mezzanine-project <项目名称> ),假设您使用名称blog作为
  7. In either the local_settings.py or settings.py file, set the DATABASES dict to use your project's database.
  8. 在local_settings.py或settings.py文件中,将DATABASES dict设置为使用项目的数据库。
  9. Run the createdb command from the mezzanine manage.py file
  10. 从夹层管理.py文件中运行createdb命令

Now it's time to start the hack-fest:

现在是时候开始hack-fest了:

  1. In your project's settings.py file, add blog to INSTALLED_APPS
  2. 在项目的settings.py文件中,将博客添加到INSTALLED_APPS
  3. Add some configuration variables to settings.py that Mezzanine is expecting: 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
  4. 添加一些配置变量的settings.py该夹层期待:PACKAGE_NAME_FILEBROWSER = “filebrowser_safe” PACKAGE_NAME_GRAPPELLI = “grappelli_safe” GRAPPELLI_INSTALLED =假ADMIN_REMOVAL = [] RATINGS_RANGE =范围(1,5)测试=假BLOG_SLUG = '' COMMENTS_UNAPPROVED_VISIBLE =真COMMENTS_REMOVED_VISIBLE = FAME COMMENTS_DEFAULT_APPROVED = True COMMENTS_NOTIFICATION_EMAILS =“,”。join(ALL_EMAILS)COMMENT_FILTER = None
  5. Add some middleware that Mezzanine is expecting: ```` ... "mezzanine.core.request.CurrentRequestMiddleware", "mezzanine.core.middleware.RedirectFallbackMiddleware", "mezzanine.core.middleware.TemplateForDeviceMiddleware", "mezzanine.core.middleware.TemplateForHostMiddleware", "mezzanine.core.middleware.AdminLoginInterfaceSelectorMiddleware", "mezzanine.core.middleware.SitePermissionMiddleware",

    Uncomment the following if using any of the SSL settings:

    "mezzanine.core.middleware.SSLRedirectMiddleware",

    "mezzanine.pages.middleware.PageMiddleware", .... ````
  6. 添加Mezzanine期待的一些中间件:````mezzanine.core.request.CurrentRequestMiddleware“,”mezzanine.core.middleware.RedirectFallbackMiddleware“,”mezzanine.core.middleware.TemplateForDeviceMiddleware“,”mezzanine.core。 middleware.TemplateForHostMiddleware“,”mezzanine.core.middleware.AdminLoginInterfaceSelectorMiddleware“,”mezzanine.core.middleware.SitePermissionMiddleware“,如果使用任何SSL设置,请取消注释以下内容:”mezzanine.core.middleware.SSLRedirectMiddleware“,”mezzanine.pages .middleware.PageMiddleware“,....````
  7. Add some INSTALLED_APPS that Mezzanine is expecting: .... "mezzanine.boot", "mezzanine.conf", "mezzanine.core", "mezzanine.generic", "mezzanine.blog", "mezzanine.forms", "mezzanine.pages", "mezzanine.galleries", "mezzanine.twitter", ....
  8. 添加一些Mezzanine期待的INSTALLED_APPS:....“mezzanine.boot”,“mezzanine.conf”,“mezzanine.core”,“mezzanine.generic”,“mezzanine.blog”,“mezzanine.forms”,“夹层楼” .pages“,”mezzanine.galleries“,”mezzanine.twitter“,....
  9. Add references to the template folders of 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'),
  10. 将夹层的模板文件夹的引用添加到TEMPLATE_DIRS元组os.path.join(BASE_PARENT,' <夹层到 mezzanine mezzanine'的路径),os.path.join(base_parent,'<夹层路径> / mezzanine /夹层/博客/模板),
  11. Finally, if your like me, you'll have to override some of the 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. So go to that file and replace the {% extends "base.html" %} with {% extends "core/templates/base.html" %}.
  12. 最后,如果你喜欢我,你将不得不覆盖夹层模板中的一些扩展路径,最明显的是“blog_post_list.html”,它只是扩展了base.html,而你希望它扩展夹层特定的基础文件。所以转到该文件并用{%extends“core / templates / base.html”%}替换{%extends“base.html”%}。

#2


4  

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文件中定义 - 您只需根据需要提取足够的内容。