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 can be installed easily using pip . In the command prompt, execute the following command: pip install django . This will download and install Django. After the installation has completed, you can verify your Django installation by executing django-admin --version in the command prompt.
pip install Django. Released: Sep 4, 2022. A high-level Python web framework that encourages rapid development and clean, pragmatic design.
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):
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>
.local_settings.py
or settings.py
file, set the DATABASES
dict to use your project's database.createdb
command from the mezzanine manage.py
fileNow it's time to start the hack-fest:
blog
to 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
....
"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'),
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" %}
.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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With