django-blog-zinnia / cmsplugin-zinnia

Bridge between django-blog-zinnia and django-cms
BSD 3-Clause "New" or "Revised" License
53 stars 46 forks source link

Recommended way of creating content programmatically, or API #54

Closed bittner closed 7 years ago

bittner commented 8 years ago

Is there a recommended way of creating content, especially with django CMS placeholders? There doesn't seem to be an API, at least not exposed, promoted or documented.

I need to create content (with a Django management command) on an empty Zinnia blog + django CMS 3.2 combo. django CMS has the create_page, add_plugin, etc. functions as part of their API. Something similar would be nice in Zinnia.

bittner commented 8 years ago

Good news! I made it work to create blog entries programmatically. The solution is a bit hacky though, could do with some code review. :smirk: Please, see the following code pieces:

  1. add_blog_entry() function (line 59+)
  2. example use (line 28+)

Some inspiration came from the test cases for Zinnia's managers, the rest from the django CMS API documentation.

Would be nice if we could have a public API in this cmsplugin too, so we could hide the ugly internals of filling the placeholder, etc. -- django CMS' create_page() could be a :scream: role model. :relieved: