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

Implement a RichTextBlock factory #13

Open
mikemonteith opened this issue Sep 6, 2018 · 2 comments
Open

Implement a RichTextBlock factory #13

mikemonteith opened this issue Sep 6, 2018 · 2 comments

Comments

@mikemonteith
Copy link

No description provided.

@mikemonteith
Copy link
Author

@Morsey187
Copy link

Things get's a bit gnarly trying resolve this, if others are having this problem and are looking for a quick fix you could return a RichText object directly instead of implementing a "factory block" class.

from wagtail.rich_text import RichText
from faker import Faker

fake = Faker()

class MyStreamBlockFactory(wagtail_factories.StreamBlockFactory):
    # image = factory.SubFactory(ImageBlockFactory)
    my_rich_text_block = factory.lazy_attribute(
        lambda _: RichText(
            f"<h2>{fake.word()}</h2>"
            f"<p>{fake.text(max_nb_chars=600)}</p>"
            f"<p>{fake.text(max_nb_chars=600)}</p>"
        )
    )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants