coderedcms icon indicating copy to clipboard operation
coderedcms copied to clipboard

[Community] Integrating CodeRed CMS with existing Wagtail project

Open mabdullahabid opened this issue 5 years ago • 4 comments

I have a few simple websites built with Wagtail. They all have separate classes for each page type e.g. blog, services, case studies. How will I go about incorporating CodeRedCMS into my already existing wagtail website?

mabdullahabid avatar Jun 29 '19 12:06 mabdullahabid

CodeRed CMS is just a layer on top of Wagtail, so you can continue to run your existing Wagtail code side by side in the same project. All of your existing code and models will continue to be editable side-by-side in the Wagtail admin with the CodeRed models.

The main difference is the page model. Wagtail has the very basic Page model, which you must inherit from. We have an much beefier base model called CoderedPage - which gives you all the extra CodeRed features. You would probably not normally inherit from CoderedPage directly, you would want to use one of our purpose-built abstract models such as CoderedWebPage or CoderedArticleIndexPage / CoderedArticlePage. These models provide all of the features such as the Bootstrap UI components, templates, SEO fields, listing/filtering child pages, etc.

On your existing models, you could also take advantage of some of the Bootstrap UI features by adding our blocks to your streamfields. Unfortunately our blocks/streamfields are not well documented yet, but you can follow the example by looking at the body field of our CoderedWebPage and CoderedArticlePage models. https://github.com/coderedcorp/coderedcms/blob/9008ea0d29458fbb8502348fcc61268a9447f9ad/coderedcms/models/page_models.py#L619 https://github.com/coderedcorp/coderedcms/blob/9008ea0d29458fbb8502348fcc61268a9447f9ad/coderedcms/models/page_models.py#L669

For example, both kinds of models can co-exist in models.py:

class MyPage(Page):
    # normal wagtail model here

class FancyPage(CoderedWebPage):
    # a fancier codered page with all of our features

We now have much better documentation about our models. Check it out: https://docs.coderedcorp.com/cms/stable/features/page_types/index.html

I would recommend starting out by creating a boilerplate coderedcms project using coderedcms start myproject, and looking at website/models.py, myproject/urls.py, and myproject/settings/base.py. Those three files have all the "meat", and you can copy most or all of that code into your existing Wagtail project.

@FlipperPA has also done some integration with an existing Wagtail project, and will probably have more practical tips. Feel free to ask questions on the Wagtail Slack in the #coderedcms channel.

vsalvino avatar Jun 29 '19 18:06 vsalvino

It might be worth adding an integration section to the docs that outlines how to go about adding CodeRed CMS to existing wagtail/django sites.

corysutyak avatar Jul 01 '19 14:07 corysutyak

I've also successfully integrated coderedcms with an existing project. As recommended above just reproduce the boilerplate that coderedcms start myproject creates, but delete the 0002_initial_data.py migration before migrating because you probably don't want to create a new site and home page alongside your existing one.

ianastewart avatar Jul 15 '19 13:07 ianastewart

It would be really nice if we could add something where we can invoke a coderedcms startapp that just creates a simple base app and prints to console what should be added to settings and urls.py.

Also, it seems like if the project name is not website it gets a bit more difficult to integration at least in my case.

safaci2000 avatar Jan 13 '20 19:01 safaci2000