Giter VIP home page Giter VIP logo

wagtailcodeblock's Introduction

Wagtail Code Block

Wagtail Code Block is a syntax highlighter block for source code for the Wagtail CMS. It features real-time highlighting in the Wagtail editor, the front end, line numbering, and support for PrismJS themes.

It uses the PrismJS library both in Wagtail Admin and the website.

Example Usage

First, add wagtailcodeblock to your INSTALLED_APPS in Django's settings. Here's a bare bones example:

from wagtail.blocks import TextBlock
from wagtail.fields import StreamField
from wagtail.models import Page
from wagtail.admin.panels import FieldPanel

from wagtailcodeblock.blocks import CodeBlock


class HomePage(Page):
    body = StreamField([
        ("heading", TextBlock()),
        ("code", CodeBlock(label='Code')),
    ])

    content_panels = Page.content_panels + [
        FieldPanel("body"),
    ]

You can also force it to use a single language or set a default language by providing a language code which must be included in your WAGTAIL_CODE_BLOCK_LANGUAGES setting:

bash_code = CodeBlock(label='Bash Code', language='bash')
any_code = CodeBlock(label='Any code', default_language='python')

Screenshot of the CMS Editor Interface

Admin in Action

Installation & Setup

To install Wagtail Code Block run:

# Wagtail 4.0 and greater
pip install wagtailcodeblock

# Wagtail 3.x
pip install wagtailcodeblock==1.28.0.0

# Wagtail 2.x
pip install wagtailcodeblock==1.25.0.2

And add wagtailcodeblock to your INSTALLED_APPS setting:

INSTALLED_APPS = [
    ...
    'wagtailcodeblock',
    ...
]

Django Settings

Line Numbers

Line numbers are enabled by default, but can be disabled in Django's settings:

WAGTAIL_CODE_BLOCK_LINE_NUMBERS = False

Copy to clipboard

Copy to clipboard is enabled by default, but can be disabled in Django's settings:

WAGTAIL_CODE_BLOCK_COPY_TO_CLIPBOARD = False

Themes

Wagtail Code Block defaults to the PrismJS "Coy" theme, which looks good with Wagtail's CMS editor design. You can choose a different theme by configuring WAGTAIL_CODE_BLOCK_THEME in your Django settings. PrismJS provides several themes:

For example, in you want to use the Solarized Light theme: WAGTAIL_CODE_BLOCK_THEME = 'solarizedlight' If you want to use the Default theme: WAGTAIL_CODE_BLOCK_THEME = None

Languages Available

You can customize the languages available by configuring WAGTAIL_CODE_BLOCK_LANGUAGES in your Django settings. By default, it will be set with these languages, since most users are in the Python web development community:

WAGTAIL_CODE_BLOCK_LANGUAGES = (
    ('bash', 'Bash/Shell'),
    ('css', 'CSS'),
    ('diff', 'diff'),
    ('html', 'HTML'),
    ('javascript', 'Javascript'),
    ('json', 'JSON'),
    ('python', 'Python'),
    ('scss', 'SCSS'),
    ('yaml', 'YAML'),
)

Each language in this setting is a tuple of the PrismJS code and a descriptive label. If you want use all available languages, here is a list:

WAGTAIL_CODE_BLOCK_LANGUAGES = (
    ('abap', 'ABAP'),
    ('abnf', 'Augmented Backus–Naur form'),
    ('actionscript', 'ActionScript'),
    ('ada', 'Ada'),
    ('antlr4', 'ANTLR4'),
    ('apacheconf', 'Apache Configuration'),
    ('apl', 'APL'),
    ('applescript', 'AppleScript'),
    ('aql', 'AQL'),
    ('arduino', 'Arduino'),
    ('arff', 'ARFF'),
    ('asciidoc', 'AsciiDoc'),
    ('asm6502', '6502 Assembly'),
    ('aspnet', 'ASP.NET (C#)'),
    ('autohotkey', 'AutoHotkey'),
    ('autoit', 'AutoIt'),
    ('bash', 'Bash + Shell'),
    ('basic', 'BASIC'),
    ('batch', 'Batch'),
    ('bison', 'Bison'),
    ('bnf', 'Backus–Naur form + Routing Backus–Naur form'),
    ('brainfuck', 'Brainfuck'),
    ('bro', 'Bro'),
    ('c', 'C'),
    ('clike', 'C-like'),
    ('cmake', 'CMake'),
    ('csharp', 'C#'),
    ('cpp', 'C++'),
    ('cil', 'CIL'),
    ('coffeescript', 'CoffeeScript'),
    ('clojure', 'Clojure'),
    ('crystal', 'Crystal'),
    ('csp', 'Content-Security-Policy'),
    ('css', 'CSS'),
    ('css-extras', 'CSS Extras'),
    ('d', 'D'),
    ('dart', 'Dart'),
    ('diff', 'Diff'),
    ('django', 'Django/Jinja2'),
    ('dns-zone-file', 'DNS Zone File'),
    ('docker', 'Docker'),
    ('ebnf', 'Extended Backus–Naur form'),
    ('eiffel', 'Eiffel'),
    ('ejs', 'EJS'),
    ('elixir', 'Elixir'),
    ('elm', 'Elm'),
    ('erb', 'ERB'),
    ('erlang', 'Erlang'),
    ('etlua', 'Embedded LUA Templating'),
    ('fsharp', 'F#'),
    ('flow', 'Flow'),
    ('fortran', 'Fortran'),
    ('ftl', 'Freemarker Template Language'),
    ('gcode', 'G-code'),
    ('gdscript', 'GDScript'),
    ('gedcom', 'GEDCOM'),
    ('gherkin', 'Gherkin'),
    ('git', 'Git'),
    ('glsl', 'GLSL'),
    ('gml', 'GameMaker Language'),
    ('go', 'Go'),
    ('graphql', 'GraphQL'),
    ('groovy', 'Groovy'),
    ('haml', 'Haml'),
    ('handlebars', 'Handlebars'),
    ('haskell', 'Haskell'),
    ('haxe', 'Haxe'),
    ('hcl', 'HCL'),
    ('http', 'HTTP'),
    ('hpkp', 'HTTP Public-Key-Pins'),
    ('hsts', 'HTTP Strict-Transport-Security'),
    ('ichigojam', 'IchigoJam'),
    ('icon', 'Icon'),
    ('inform7', 'Inform 7'),
    ('ini', 'Ini'),
    ('io', 'Io'),
    ('j', 'J'),
    ('java', 'Java'),
    ('javadoc', 'JavaDoc'),
    ('javadoclike', 'JavaDoc-like'),
    ('javascript', 'JavaScript'),
    ('javastacktrace', 'Java stack trace'),
    ('jolie', 'Jolie'),
    ('jq', 'JQ'),
    ('jsdoc', 'JSDoc'),
    ('js-extras', 'JS Extras'),
    ('js-templates', 'JS Templates'),
    ('json', 'JSON'),
    ('jsonp', 'JSONP'),
    ('json5', 'JSON5'),
    ('julia', 'Julia'),
    ('keyman', 'Keyman'),
    ('kotlin', 'Kotlin'),
    ('latex', 'LaTeX'),
    ('less', 'Less'),
    ('lilypond', 'Lilypond'),
    ('liquid', 'Liquid'),
    ('lisp', 'Lisp'),
    ('livescript', 'LiveScript'),
    ('lolcode', 'LOLCODE'),
    ('lua', 'Lua'),
    ('makefile', 'Makefile'),
    ('markdown', 'Markdown'),
    ('markup', 'Markup + HTML + XML + SVG + MathML'),
    ('markup-templating', 'Markup templating'),
    ('matlab', 'MATLAB'),
    ('mel', 'MEL'),
    ('mizar', 'Mizar'),
    ('monkey', 'Monkey'),
    ('n1ql', 'N1QL'),
    ('n4js', 'N4JS'),
    ('nand2tetris-hdl', 'Nand To Tetris HDL'),
    ('nasm', 'NASM'),
    ('nginx', 'nginx'),
    ('nim', 'Nim'),
    ('nix', 'Nix'),
    ('nsis', 'NSIS'),
    ('objectivec', 'Objective-C'),
    ('ocaml', 'OCaml'),
    ('opencl', 'OpenCL'),
    ('oz', 'Oz'),
    ('parigp', 'PARI/GP'),
    ('parser', 'Parser'),
    ('pascal', 'Pascal + Object Pascal'),
    ('pascaligo', 'Pascaligo'),
    ('pcaxis', 'PC Axis'),
    ('perl', 'Perl'),
    ('php', 'PHP'),
    ('phpdoc', 'PHPDoc'),
    ('php-extras', 'PHP Extras'),
    ('plsql', 'PL/SQL'),
    ('powershell', 'PowerShell'),
    ('processing', 'Processing'),
    ('prolog', 'Prolog'),
    ('properties', '.properties'),
    ('protobuf', 'Protocol Buffers'),
    ('pug', 'Pug'),
    ('puppet', 'Puppet'),
    ('pure', 'Pure'),
    ('python', 'Python'),
    ('q', 'Q (kdb+ database)'),
    ('qore', 'Qore'),
    ('r', 'R'),
    ('jsx', 'React JSX'),
    ('tsx', 'React TSX'),
    ('renpy', 'Ren\'py'),
    ('reason', 'Reason'),
    ('regex', 'Regex'),
    ('rest', 'reST (reStructuredText)'),
    ('rip', 'Rip'),
    ('roboconf', 'Roboconf'),
    ('robot-framework', 'Robot Framework'),
    ('ruby', 'Ruby'),
    ('rust', 'Rust'),
    ('sas', 'SAS'),
    ('sass', 'Sass (Sass)'),
    ('scss', 'Sass (Scss)'),
    ('scala', 'Scala'),
    ('scheme', 'Scheme'),
    ('shell-session', 'Shell Session'),
    ('smalltalk', 'Smalltalk'),
    ('smarty', 'Smarty'),
    ('solidity', 'Solidity (Ethereum)'),
    ('sparql', 'SPARQL'),
    ('splunk-spl', 'Splunk SPL'),
    ('sqf', 'SQF: Status Quo Function (Arma 3)'),
    ('sql', 'SQL'),
    ('soy', 'Soy (Closure Template)'),
    ('stylus', 'Stylus'),
    ('swift', 'Swift'),
    ('tap', 'TAP'),
    ('tcl', 'Tcl'),
    ('textile', 'Textile'),
    ('toml', 'TOML'),
    ('tt2', 'Template Toolkit 2'),
    ('twig', 'Twig'),
    ('typescript', 'TypeScript'),
    ('t4-cs', 'T4 Text Templates (C#)'),
    ('t4-vb', 'T4 Text Templates (VB)'),
    ('t4-templating', 'T4 templating'),
    ('vala', 'Vala'),
    ('vbnet', 'VB.Net'),
    ('velocity', 'Velocity'),
    ('verilog', 'Verilog'),
    ('vhdl', 'VHDL'),
    ('vim', 'vim'),
    ('visual-basic', 'Visual Basic'),
    ('wasm', 'WebAssembly'),
    ('wiki', 'Wiki markup'),
    ('xeora', 'Xeora + XeoraCube'),
    ('xojo', 'Xojo (REALbasic)'),
    ('xquery', 'XQuery'),
    ('yaml', 'YAML'),
    ('zig', 'Zig'),
)

What's With the Versioning?

Our version numbers are based on the underlying version of PrismJS we use. For example, if we are using PrismJS 1.28.0, our versions will be named 1.28.0.X.

Release Notes & Contributors

Project Maintainers

This package was created by the staff of Wharton Research Data Services. We are thrilled that The Wharton School allows us a certain amount of time to contribute to open-source projects. We add features as they are necessary for our projects, and try to keep up with Issues and Pull Requests as best we can. Due to constraints of time (our full time jobs!), Feature Requests without a Pull Request may not be implemented, but we are always open to new ideas and grateful for contributions and our users.

wagtailcodeblock's People

Contributors

andytwoods avatar arturinsh avatar blafving avatar bstepa avatar cybelew avatar flipperpa avatar fourfridays avatar gabigab117 avatar lucasmoeskops avatar markhorgan avatar mwort avatar ndevox avatar ramiboutas avatar salahaddin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

wagtailcodeblock's Issues

Package future with Draftail.

Recently, Wagtail 2.0 was released and it brings a new feature: Draftail, using Draft.js, a powerful jseditor.

One of the package derivated from Wagtail, Puput, is using the new feature API for inject code in the RichTextFields: APSL/puput@be7eacb#diff-2e7915c4db5fe6d98fea8c5525939930
You can see a prism.js plugin for Draftail: https://github.com/withspectrum/draft-js-prism-plugin

So, my question is, what's about this Package? What is the future for this package?

There is a content related issue: #9

Problem with the code label

Hi, i have a code label that is added from nowhere and i can't remove it, there is nothing in the template that adds that but still the following code is added on the page:

image

and the result is that:

image

How to proceed to remove that label ?

Add setup/install instructions to README

A very simple one - but worth clarifying for those who aren't sure.

I think it is worth showing the pip install command and that wagtailcodeblock needs adding to INSTALLED_APPS in the README.MD

Template tags for rendering

Hey, thank you for you work.

I'm using your package and i'm trying to improve it, you can see my pr about it.

I'm thinking about how can i render the code block and i did make this in my code:

<div class="">

    <link href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.8.3/themes/prism-coy.min.css"
          rel="stylesheet"/>
    <pre>
        <code class="language-{{ self.code.language }}">{{ self.code.code }}</code>
    </pre>
    {% if self.reference %}
        <div class="caption">
            Reference <a href="{{ self.reference }}">here.</a>
        </div>
    {% endif %}
    <script defer
            src='https://cdnjs.cloudflare.com/ajax/libs/prism/1.8.3/prism.min.js'></script>
    <script defer
            src='https://cdnjs.cloudflare.com/ajax/libs/prism/1.8.3/components/prism-{{ self.code.language }}.min.js'></script>
</div>

This is the template for my code; but if you think about it, if i have many code blocks in the body, this template will be rendered many times, getting the same template one by one time, the same template. But it is only useful with the specify language page, getting the other two files won't be useful and it will terrible for performance too.

We have two options, put in the documentation that user have to render it in the base template, or create a template tag. I think the second option will be better, why? Because actually we have two get the latest version, and because we want too have our template.

I was thinking about print the theme option in the template, but i think it isn't a securely option.

In addition, if we load the prism main file in a template tag in script body, we have to upload the specific language files after it, so, we have to make other template tag, or, create one that update first this file, and after the other files, in the same way that admin(it could have a difficult getting all code laguange values from the body. If you put the specific file before the main file, the highlighting will be wrong.

So, what do you think about it?

Code block moves off screen in editor

Hi,
I have just tried to use wagtailcodeblock 0.3.1 in my wagtail site and the frontend bit appears to be fine when I preview.
Unfortunately, when I saved the code the Language selected and code input boxes 'jumped' to the right and now I'm unable to access various parts of the editing UI including adding/removing blocks.

The problem occurs in both Safari, Chrome and Firefox on macOS 10.13.1.

screenshot of wagtail code block bug

Is there any other information you need from me to try and figure out what is going wrong?

Replacing a theme

Hello, what is the proper way to extend wagtailcodeblock with other themes? For example, if I will download one of these? (I mostly want to use FiraCode font for code.)

404's for some non existent CDNJS files

Version Number

prism.js 1.29.0
Wagtail 5.0

Problem Statement

  • When copy-to-cipboard option is set to True the app tries to get the following non-existent file https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/plugins/copy-to-clipboard/prism-copy-to-clipboard.min.css that returns a 404 in the browser console.
  • When syntax highlighter language is set to HTML the app tries to get the following non-existent file https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/components/prism-html.min.js and returns a 404 in the browser console

Proposed Solution

For the copy-to-clipboard 404 error we can drop the following code:

For the HTML language 404 we can add if language check:

Allow more options for using prismjs

The default right now is to use the CDN, but this isn't always what people want to do.

For example I use NPM for several other packages and tend to bundle my code. Adding a CDN download just adds extra latency.

I'd propose adding a setting to turn off the use of the CDN so you can add your own script.

This would also have the added benefit of being able to add the script once, instead of having it execute multiple times (which would be the default).

I will provide a PR for this when I have a bit of time (hopefully today).

Wagtailcodeblock is broken in wagtail 4.2.

When trying to use wagtailcodeblock in a streamfield, in the admin, I get the following Javascript error which prevents the streamfield from loading.

It worked fine in wagtail 4.1, but it's broken in 4.2.

Uncaught TypeError: Class constructor g cannot be invoked without 'new'
    at new CodeBlockDefinition (wagtailcodeblock.js:2:60)
    at t.value (VM90 telepath.js:1:3635)
    at VM90 telepath.js:1:3030
    at Array.map (<anonymous>)
    at t.value (VM90 telepath.js:1:3004)
    at VM90 telepath.js:1:3030
    at Array.map (<anonymous>)
    at t.value (VM90 telepath.js:1:3004)
    at VM90 telepath.js:1:3030
    at Array.map (<anonymous>)

Admin Clientside Error - Wagtail Release >= 2.13

Clientside error on admin when using wagtailcodeblock "Uncaught ReferenceError: Prism is not defined at prism_repaint". I believe its due to Wagtail recent releases; the error is shown when using versions >= 2.13.

When viewing the page live everything works fine, the error is only shown on the Wagtail Admin.

image

PrismJS extremely slow

Hi,
What I can do to increase loading time prism.js file on the frontend?
According to Google Speed Insight it takes 3 383 ms to load this file.

The line numbering and the syntax highlighter doesn't work properly.

When I reload the website sometimes the syntax highlighting and the numbering doesn't appear. If I keep reloading the webpage multiple times, then it appears after several tries. And if I reload it one more time, then the highlighting and numbering disappear again.

It's an issue only encountered when rendering on templates, not the admin panel.

Appearing now
Screenshot 2022-12-22 at 07-37-24 Coffee Spiller

on next reload, disappearing.
Screenshot 2022-12-22 at 07-38-37 Coffee Spiller

Switch to Highlight.JS from PrismJS - Discuss

PrismJS no longer seems to be maintained. There are also some underlying issues with CSS namespacing that conflict with Wagtail's admin, particularly around the CSS class named comment.

I'm considering switching to highlight.js as our underlying syntax highlighting library.

Pros:

  • Resolves namespace conflicts
  • Actively maintained
  • More language support
  • More theme choice

Cons:

  • Current themes will no longer be supported
  • It's a big change, and other backwards incompatibilities might be found.

I wanted to open this issue for discussion to our users before moving in this direction. Thoughts?

difficult to override styles

Thanks for this useful library!

I'm having trouble overriding styles - I think because your block includes the prism css with the content, so it takes precedence over my site-wide styles that are included in the page header.

Wondering if instead the prism styles could be loaded in the header if the page includes a code block, so that local styles could be given precedence. Could maybe be done as a new template tag, or a revised version of the existing load_prism_css tag.

Need some hints for wagtail 5 Compatibility

Hi, Flipper,

First of all, I want to express my gratitude for your hard work on this project. I really appreciate the effort you've put into creating it. However, I've encountered an issue when trying to use it with Wagtail 5. While it works perfectly fine with Wagtail 4.2, it seems to break with Wagtail 5.

I've spent the last two days trying to debug and identify the problem, but unfortunately, I haven't been able to find a solution yet. I was wondering if you could provide me with some hints or guidance on how to fix it.

Here's what's currently happening: whenever I add a code block to the stream field, the entire stream field disappears. Additionally, I sometimes encounter the following error:

    self.full_clean()
project/macaw/venv/lib/python3.9/site-packages/django/forms/forms.py", line 433, in full_clean
    self._clean_fields()
/project/macaw/venv/lib/python3.9/site-packages/django/forms/forms.py", line 440, in _clean_fields
    value = bf.initial if field.disabled else bf.data
project/macaw/venv/lib/python3.9/site-packages/django/forms/boundfield.py", line 127, in data
    return self.form._widget_data_value(self.field.widget, self.html_name)
project/macaw/venv/lib/python3.9/site-packages/django/forms/forms.py", line 224, in _widget_data_value
    return widget.value_from_datadict(self.data, self.files, html_name)
/project/macaw/venv/lib/python3.9/site-packages/wagtail/blocks/base.py", line 579, in value_from_datadict
    return self.block_def.value_from_datadict(data, files, name)
/project/macaw/venv/lib/python3.9/site-packages/wagtail/blocks/stream_block.py", line 116, in value_from_datadict
    count = int(data["%s-count" % prefix])
project/macaw/venv/lib/python3.9/site-packages/django/utils/datastructures.py", line 86, in __getitem__
    raise MultiValueDictKeyError(key)
django.utils.datastructures.MultiValueDictKeyError: 'content-count'

Any help or suggestions you can provide would be greatly appreciated.

Thank you once again for your contributions and support.

MultiValueDictKeyError in Wagtail 4.2

I keep getting an error in the terminal when I create a new page that is using wagtailcodeblock as a streamfield, also all of my other streamfields go missing in the page admin and the terminal shows the error listed below.

I am using wagtailcodeblock 1.28.0.0. with Wagtail 4.2 and Django 4.1.7. I installed all of the dependencies that the Wagtail doc’s recommended.

class HomePage(Page):

    content = StreamField([
        ('paragraph', blocks.RichTextBlock()),
        ('image', ImageChooserBlock()),
        ('code', CodeBlock())
    ], use_json_field=True)


    content_panels = Page.content_panels + [
        FieldPanel("content"),
    ]

This is the terminal error:

[02/Mar/2023 00:59:10] "GET /admin/pages/3/edit/ HTTP/1.1" 200 78981
[02/Mar/2023 00:59:10] "GET /admin/jsi18n/ HTTP/1.1" 200 3343
[02/Mar/2023 00:59:10] "GET /admin/sprite-cede3484/ HTTP/1.1" 200 108109
[02/Mar/2023 00:59:10] "GET /admin/pages/3/edit/preview/?in_preview_panel=true&mode= HTTP/1.1" 200 1844
[02/Mar/2023 00:59:10] "DELETE /admin/pages/3/edit/preview/ HTTP/1.1" 200 17
[02/Mar/2023 00:59:10] "GET /admin/sprite-cede3484/ HTTP/1.1" 200 108109
Internal Server Error: /admin/pages/3/edit/preview/
Traceback (most recent call last):
  File "/home/scott/django-sandbox/wagtailcodeblock/env/lib/python3.9/site-packages/django/utils/datastructures.py", line 84, in __getitem__
    list_ = super().__getitem__(key)
KeyError: 'content-count'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/scott/django-sandbox/wagtailcodeblock/env/lib/python3.9/site-packages/django/core/handlers/exception.py", line 56, in inner
    response = get_response(request)
  File "/home/scott/django-sandbox/wagtailcodeblock/env/lib/python3.9/site-packages/django/core/handlers/base.py", line 197, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/home/scott/django-sandbox/wagtailcodeblock/env/lib/python3.9/site-packages/django/views/decorators/cache.py", line 62, in _wrapped_view_func
    response = view_func(request, *args, **kwargs)
  File "/home/scott/django-sandbox/wagtailcodeblock/env/lib/python3.9/site-packages/wagtail/admin/urls/__init__.py", line 175, in wrapper
    return view_func(request, *args, **kwargs)
  File "/home/scott/django-sandbox/wagtailcodeblock/env/lib/python3.9/site-packages/wagtail/admin/auth.py", line 182, in decorated_view
    response = view_func(request, *args, **kwargs)
  File "/home/scott/django-sandbox/wagtailcodeblock/env/lib/python3.9/site-packages/django/views/generic/base.py", line 103, in view
    return self.dispatch(request, *args, **kwargs)
  File "/home/scott/django-sandbox/wagtailcodeblock/env/lib/python3.9/site-packages/wagtail/admin/views/generic/preview.py", line 30, in dispatch
    return super().dispatch(request, *args, **kwargs)
  File "/home/scott/django-sandbox/wagtailcodeblock/env/lib/python3.9/site-packages/django/views/generic/base.py", line 142, in dispatch
    return handler(request, *args, **kwargs)
  File "/home/scott/django-sandbox/wagtailcodeblock/env/lib/python3.9/site-packages/wagtail/admin/views/generic/preview.py", line 74, in post
    is_valid = form.is_valid()
  File "/home/scott/django-sandbox/wagtailcodeblock/env/lib/python3.9/site-packages/wagtail/admin/forms/pages.py", line 176, in is_valid
    return super().is_valid()
  File "/home/scott/django-sandbox/wagtailcodeblock/env/lib/python3.9/site-packages/modelcluster/forms.py", line 343, in is_valid
    form_is_valid = super().is_valid()
  File "/home/scott/django-sandbox/wagtailcodeblock/env/lib/python3.9/site-packages/django/forms/forms.py", line 205, in is_valid
    return self.is_bound and not self.errors
  File "/home/scott/django-sandbox/wagtailcodeblock/env/lib/python3.9/site-packages/django/forms/forms.py", line 200, in errors
    self.full_clean()
  File "/home/scott/django-sandbox/wagtailcodeblock/env/lib/python3.9/site-packages/django/forms/forms.py", line 437, in full_clean
    self._clean_fields()
  File "/home/scott/django-sandbox/wagtailcodeblock/env/lib/python3.9/site-packages/django/forms/forms.py", line 444, in _clean_fields
    value = bf.initial if field.disabled else bf.data
  File "/home/scott/django-sandbox/wagtailcodeblock/env/lib/python3.9/site-packages/django/forms/boundfield.py", line 127, in data
    return self.form._widget_data_value(self.field.widget, self.html_name)
  File "/home/scott/django-sandbox/wagtailcodeblock/env/lib/python3.9/site-packages/django/forms/forms.py", line 224, in _widget_data_value
    return widget.value_from_datadict(self.data, self.files, html_name)
  File "/home/scott/django-sandbox/wagtailcodeblock/env/lib/python3.9/site-packages/wagtail/blocks/base.py", line 576, in value_from_datadict
    return self.block_def.value_from_datadict(data, files, name)
  File "/home/scott/django-sandbox/wagtailcodeblock/env/lib/python3.9/site-packages/wagtail/blocks/stream_block.py", line 104, in value_from_datadict
    count = int(data["%s-count" % prefix])
  File "/home/scott/django-sandbox/wagtailcodeblock/env/lib/python3.9/site-packages/django/utils/datastructures.py", line 86, in __getitem__
    raise MultiValueDictKeyError(key)
django.utils.datastructures.MultiValueDictKeyError: 'content-count'
[02/Mar/2023 00:59:10] "POST /admin/pages/3/edit/preview/ HTTP/1.1" 500 152270


Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.