Sorry, don’t have enough time to write a code sample right now, but here is a more detailed description of the steps:
- Create a new application with all the contents copied from mezzanine.blog. Let’s call it multiblog. Add it to installed apps. - In models.py add a new Blog model inheriting from Slugged (this will give it a title and slug). Register it in the admin so you can add Blog instances. - Add foreign keys to this new Blog model to BlogPost and BlogCategory, so each post and category will belong to one blog. Create the required migrations. Make sure you expose the FK field in the admin so each post and category can choose to which Blog they will belong to. - Rewrite urls.py to account for the Blog slug. For example: “/blog/some-post” becomes “/blog/blog-slug/some-post”. The regex for the URL should capture the blog slug so it will be passed to the view. - Rewrite views.py to account for the new blog slug, and modify the querysets to only look into the posts / categories for a particular blog. Something like BlogPost.objects.filter(blog__slug=<captured slug>). - Optionally rewrite the template-finding logic in the view to allow you to use different (per-blog) templates. For example, you could have the view load templates by looking inside folders that match the blog slug, like “templates/blog/<variable slug>/blog_post_detail.html” and “templates/blog/<variable slug>/blog_post_list.html”. Hope that helps! From: Amir Sent: Thursday, August 9, 2018 7:48 AM To: Mezzanine Users Subject: [mezzanine-users] Re: Multiple Blogs This suggestion of yours is remarkable Eduardo and I am craving to have multiple and separated blogs. I am a bit new to Django though, Could you elaborate more on the details please? I could open a topic on StackOverflow if you would prefer. This would be a huge help bro. On Tuesday, March 3, 2015 at 6:33:33 AM UTC+3:30, Eduardo Rivas wrote: Hello Dennis. I actually needed to do this for a project a few years ago. As far a I know, Mezzanine doesn't support multiple blogs out of the box. What I did was create a "Blog" model, which simply had a slug and title, and then add it as FK to the standard BlogPost and BlogCategory models. After that, it's just a matter of updating urls and views to account for a blog_slug parameter to get the correct Blog instance. If you want to get fancy, you can create "base" templates for each blog. That way, you get unique blog posts, categories and templates for each blog. You'll also need to modify the queries made by the Admin to only return the subset of BlogPost's that match a Blog instance in particular. Important note: this of course implies you're "forking" Mezzanine's blog app, so you will have to maintain it by yourself and install it in place of the default one. -- You received this message because you are subscribed to a topic in the Google Groups "Mezzanine Users" group. To unsubscribe from this topic, visit https://groups.google.com/d/topic/mezzanine-users/LFhT0oryfEI/unsubscribe. To unsubscribe from this group and all its topics, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "Mezzanine Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
