add blog model stuff
This commit is contained in:
parent
84b77d2d6a
commit
004195e843
11 changed files with 137 additions and 2 deletions
0
project/blog/__init__.py
Normal file
0
project/blog/__init__.py
Normal file
34
project/blog/migrations/0001_initial.py
Normal file
34
project/blog/migrations/0001_initial.py
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Generated by Django 1.10.3 on 2016-11-24 20:51
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
import wagtail.wagtailcore.fields
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
initial = True
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('wagtailcore', '0030_index_on_pagerevision_created_at'),
|
||||||
|
('wagtailimages', '0015_fill_filter_spec_field'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='BlogPage',
|
||||||
|
fields=[
|
||||||
|
('page_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='wagtailcore.Page')),
|
||||||
|
('date', models.DateField(verbose_name='Post date')),
|
||||||
|
('intro', models.CharField(max_length=250)),
|
||||||
|
('body', wagtail.wagtailcore.fields.RichTextField(blank=True)),
|
||||||
|
('main_image', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='wagtailimages.Image')),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'abstract': False,
|
||||||
|
},
|
||||||
|
bases=('wagtailcore.page',),
|
||||||
|
),
|
||||||
|
]
|
0
project/blog/migrations/__init__.py
Normal file
0
project/blog/migrations/__init__.py
Normal file
32
project/blog/models.py
Normal file
32
project/blog/models.py
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
from django.db import models
|
||||||
|
|
||||||
|
from wagtail.wagtailcore.models import Page
|
||||||
|
from wagtail.wagtailcore.fields import RichTextField
|
||||||
|
from wagtail.wagtailadmin.edit_handlers import FieldPanel
|
||||||
|
from wagtail.wagtailimages.edit_handlers import ImageChooserPanel
|
||||||
|
from wagtail.wagtailsearch import index
|
||||||
|
|
||||||
|
|
||||||
|
class BlogPage(Page):
|
||||||
|
main_image = models.ForeignKey(
|
||||||
|
'wagtailimages.Image',
|
||||||
|
null=True,
|
||||||
|
blank=True,
|
||||||
|
on_delete=models.SET_NULL,
|
||||||
|
related_name='+'
|
||||||
|
)
|
||||||
|
date = models.DateField("Post date")
|
||||||
|
intro = models.CharField(max_length=250)
|
||||||
|
body = RichTextField(blank=True)
|
||||||
|
|
||||||
|
search_fields = Page.search_fields + [
|
||||||
|
index.SearchField('intro'),
|
||||||
|
index.SearchField('body'),
|
||||||
|
]
|
||||||
|
|
||||||
|
content_panels = Page.content_panels + [
|
||||||
|
FieldPanel('date'),
|
||||||
|
ImageChooserPanel('main_image'),
|
||||||
|
FieldPanel('intro'),
|
||||||
|
FieldPanel('body'),
|
||||||
|
]
|
30
project/common/migrations/0001_initial.py
Normal file
30
project/common/migrations/0001_initial.py
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Generated by Django 1.10.3 on 2016-11-24 21:20
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
import wagtail.wagtailcore.fields
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
initial = True
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('wagtailcore', '0030_index_on_pagerevision_created_at'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='SectionIndexPage',
|
||||||
|
fields=[
|
||||||
|
('page_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='wagtailcore.Page')),
|
||||||
|
('intro', wagtail.wagtailcore.fields.RichTextField(blank=True)),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'abstract': False,
|
||||||
|
},
|
||||||
|
bases=('wagtailcore.page',),
|
||||||
|
),
|
||||||
|
]
|
0
project/common/migrations/__init__.py
Normal file
0
project/common/migrations/__init__.py
Normal file
11
project/common/models.py
Normal file
11
project/common/models.py
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
from wagtail.wagtailcore.models import Page
|
||||||
|
from wagtail.wagtailcore.fields import RichTextField
|
||||||
|
from wagtail.wagtailadmin.edit_handlers import FieldPanel
|
||||||
|
|
||||||
|
|
||||||
|
class SectionIndexPage(Page):
|
||||||
|
intro = RichTextField(blank=True)
|
||||||
|
|
||||||
|
content_panels = Page.content_panels + [
|
||||||
|
FieldPanel('intro', classname="full")
|
||||||
|
]
|
|
@ -1,5 +1,3 @@
|
||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
from wagtail.wagtailcore.models import Page
|
from wagtail.wagtailcore.models import Page
|
||||||
from wagtail.wagtailcore.fields import RichTextField
|
from wagtail.wagtailcore.fields import RichTextField
|
||||||
from wagtail.wagtailadmin.edit_handlers import FieldPanel
|
from wagtail.wagtailadmin.edit_handlers import FieldPanel
|
||||||
|
|
|
@ -45,6 +45,7 @@ INSTALLED_APPS = [
|
||||||
'django.contrib.messages',
|
'django.contrib.messages',
|
||||||
'django.contrib.staticfiles',
|
'django.contrib.staticfiles',
|
||||||
|
|
||||||
|
'project.blog',
|
||||||
'project.common',
|
'project.common',
|
||||||
'project.home',
|
'project.home',
|
||||||
'project.search',
|
'project.search',
|
||||||
|
|
18
templates/blog/blog_page.html
Normal file
18
templates/blog/blog_page.html
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
{% extends "base.html" %}
|
||||||
|
|
||||||
|
{% load wagtailcore_tags wagtailimages_tags %}
|
||||||
|
|
||||||
|
{% block body_class %}template-blogpage{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<h1>{{ page.title }}</h1>
|
||||||
|
<p class="meta">{{ page.date }}</p>
|
||||||
|
|
||||||
|
{% if page.main_image %}
|
||||||
|
{% image page.main_image width-400 %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
<div class="intro">{{ page.intro }}</div>
|
||||||
|
|
||||||
|
{{ page.body|richtext }}
|
||||||
|
{% endblock %}
|
11
templates/common/section_index_page.html
Normal file
11
templates/common/section_index_page.html
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
{% extends "base.html" %}
|
||||||
|
|
||||||
|
{% load wagtailcore_tags %}
|
||||||
|
|
||||||
|
{% block body_class %}template-indexpage{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<h1>{{ page.title }}</h1>
|
||||||
|
|
||||||
|
<div class="intro">{{ page.intro|richtext }}</div>
|
||||||
|
{% endblock %}
|
Reference in a new issue