Skip to content

Commit d33af13

Browse files
committed
Add example
1 parent 9241877 commit d33af13

File tree

14 files changed

+153
-83
lines changed

14 files changed

+153
-83
lines changed

cms/cms/templates/base.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@
3232
{% block content %}{% endblock %}
3333

3434
{# Global javascript #}
35+
{% render_bundle 'main' %}
3536
<script type="text/javascript" src="{% static 'js/cms.js' %}"></script>
3637

3738
{% block extra_js %}
3839
{# Override this in templates to add extra javascript #}
3940
{% endblock %}
4041

41-
{% render_bundle 'main' %}
4242
</body>
4343
</html>

cms/db.sqlite3

4 KB
Binary file not shown.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Generated by Django 2.2.15 on 2020-08-30 13:29
2+
3+
from django.db import migrations
4+
import wagtail.core.fields
5+
6+
7+
class Migration(migrations.Migration):
8+
9+
dependencies = [
10+
('home', '0002_create_homepage'),
11+
]
12+
13+
operations = [
14+
migrations.AddField(
15+
model_name='homepage',
16+
name='body',
17+
field=wagtail.core.fields.RichTextField(blank=True),
18+
),
19+
]
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Generated by Django 2.2.15 on 2020-08-30 13:38
2+
3+
from django.db import migrations
4+
import wagtail.core.blocks
5+
import wagtail.core.fields
6+
import wagtail.images.blocks
7+
8+
9+
class Migration(migrations.Migration):
10+
11+
dependencies = [
12+
('home', '0003_homepage_body'),
13+
]
14+
15+
operations = [
16+
migrations.AlterField(
17+
model_name='homepage',
18+
name='body',
19+
field=wagtail.core.fields.StreamField([('heading', wagtail.core.blocks.CharBlock(classname='full title')), ('paragraph', wagtail.core.blocks.RichTextBlock()), ('image', wagtail.images.blocks.ImageChooserBlock())]),
20+
),
21+
]

cms/home/models.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,20 @@
11
from django.db import models
22

3+
from wagtail.core import blocks
34
from wagtail.core.models import Page
5+
from wagtail.core.fields import RichTextField, StreamField
6+
from wagtail.admin.edit_handlers import FieldPanel
7+
from wagtail.admin.edit_handlers import FieldPanel, StreamFieldPanel
8+
from wagtail.images.blocks import ImageChooserBlock
49

510

611
class HomePage(Page):
7-
pass
12+
body = StreamField([
13+
('heading', blocks.CharBlock(classname="full title")),
14+
('paragraph', blocks.RichTextBlock()),
15+
('image', ImageChooserBlock()),
16+
])
17+
18+
content_panels = Page.content_panels + [
19+
StreamFieldPanel('body', classname="full"),
20+
]
Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
{% extends "base.html" %}
22
{% load static %}
3+
{% load wagtailcore_tags %}
34

45
{% block body_class %}template-homepage{% endblock %}
56

67
{% block extra_css %}
78

9+
810
{% comment %}
911
Delete the line below if you're just getting started and want to remove the welcome screen!
1012
{% endcomment %}
@@ -13,9 +15,23 @@
1315

1416
{% block content %}
1517

16-
{% comment %}
17-
Delete the line below if you're just getting started and want to remove the welcome screen!
18-
{% endcomment %}
19-
{% include 'home/welcome_page.html' %}
18+
<div>
19+
<div id="vue-count-button"></div>
20+
<div id="vue-sidebar"></div>
21+
</div>
22+
<article>
23+
{% for block in page.body %}
24+
{% if block.block_type == 'heading' %}
25+
{{ block.value|json_script:'header_title'}}
26+
{{ block.value|json_script:'header_title2'}}
27+
<h1>{{ block.value }}</h1>
28+
{% endif %}
29+
{% if block.block_type == 'paragraph' %}
30+
<p>{{ block.value }}</p>
31+
{% endif %}
32+
33+
{% endfor %}
34+
</article>
35+
2036

2137
{% endblock content %}

cms/home/templates/home/welcome_page.html

Lines changed: 0 additions & 53 deletions
This file was deleted.

frontend/src/App.vue

Lines changed: 0 additions & 20 deletions
This file was deleted.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<template>
2+
<div>
3+
<h2>This is a Vue 3 component!!</h2>
4+
<button @click="increase">Clicked {{ count }} times.</button>
5+
</div>
6+
</template>
7+
<script lang="ts">
8+
import { ref } from 'vue';
9+
import { get } from '../utils/django-variables';
10+
11+
export default {
12+
setup() {
13+
const djangoVariables = get('header_title', 'header_title2');
14+
console.log(djangoVariables);
15+
16+
const count = ref(0);
17+
const increase = () => {
18+
count.value++;
19+
};
20+
21+
return {
22+
count,
23+
increase
24+
};
25+
}
26+
};
27+
</script>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<template>
2+
<div>
3+
<h3>Sidebar</h3>
4+
5+
<input type="text" v-model="search.text" />
6+
<p>{{ search.text }}</p>
7+
</div>
8+
</template>
9+
10+
<script lang="ts">
11+
import { ref, reactive } from 'vue';
12+
export default {
13+
setup() {
14+
const search = reactive({
15+
text: 'abc'
16+
});
17+
return {
18+
search
19+
};
20+
}
21+
};
22+
</script>
23+

0 commit comments

Comments
 (0)