Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document importing content #409

Open
2 tasks
yakky opened this issue Jan 6, 2018 · 7 comments
Open
2 tasks

Document importing content #409

yakky opened this issue Jan 6, 2018 · 7 comments

Comments

@yakky
Copy link
Member

yakky commented Jan 6, 2018

  • Wordpress
  • Custom code

See the following gists as reference:

Related to #406

@kynsi
Copy link
Contributor

kynsi commented Jan 19, 2018

I got this work but I did have to add the BlogConfig instance. Something like "config = BlogConfig.objects.get(pk=1)".

@yakky
Copy link
Member Author

yakky commented Jan 19, 2018

@kynsi yes, that gist is very old.
We need to port it to the newest requirements and kind of make it "official"

@kynsi
Copy link
Contributor

kynsi commented Jan 21, 2018

Is it also possible to use plugins in this fashion? I'm trying this code but it doesn't work:
for category in categories.language(language).filter(app_config=config): ...
placeholder = page.placeholders.get(slot='content')
add_plugin(placeholder, plugin_type='BlogLatestEntriesPlugin', language=language, template_folder='Masonry style',app_config=config,latestpostsplugin='LatestPostsPlugin', categories=category)

@yakky
Copy link
Member Author

yakky commented Jan 21, 2018

I think you added too much arguments. latestpostplugin doesn't belong there.
See the django CMS full documentation http://djangocms.readthedocs.io/en/latest/reference/api_references/#cms.api.add_plugin

@kynsi
Copy link
Contributor

kynsi commented Jan 21, 2018

I know, but it keeps saying that latestpostplugin doesn't have a value..

@kynsi
Copy link
Contributor

kynsi commented Jan 22, 2018

Here's the exact error:
ValueError: "<LatestPostsPlugin: 5 latest articles by tag>" needs to have a value for field "latestpostsplugin" before this many-to-many relationship can be used.

@yakky
Copy link
Member Author

yakky commented Jan 24, 2018

You cannot provide ManyToMany field values in add_plugin as theorm will try to save the m2m data before the object is ready
do something like:

plugin = add_plugin(placeholder, plugin_type='BlogLatestEntriesPlugin', language=language, template_folder='Masonry style',app_config=config)
plugin.add(category)

This should work

@yakky yakky added this to the 1.0 milestone Apr 3, 2018
@yakky yakky modified the milestones: 1.0, 1.0.x Nov 7, 2019
@yakky yakky removed this from the 1.1 milestone May 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants