Skip to content

Commit

Permalink
Add image and intro fields to breads page
Browse files Browse the repository at this point in the history
  • Loading branch information
shacker committed Feb 17, 2017
1 parent 988fb54 commit bc54cb4
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 2 deletions.
27 changes: 27 additions & 0 deletions bakerydemo/breads/migrations/0002_auto_20170217_0853.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.5 on 2017-02-17 08:53
from __future__ import unicode_literals

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
('wagtailimages', '0018_remove_rendition_filter'),

This comment has been minimized.

Copy link
@daaray

daaray Feb 18, 2017

Contributor

This migration is missing from the repo. I pulled master and received this output when running pythpn manage.py migrate:

django.db.migrations.exceptions.NodeNotFoundError: Migration breads.0002_auto_20170217_0853 dependencies reference nonexistent parent node ('wagtailimages', '0018_remove_rendition_filter')

This comment has been minimized.

Copy link
@shacker

shacker Feb 18, 2017

Author Contributor

@daaray I'm not sure what to think, as that migration file is definitely present in the repo:
https://github.com/wagtail/bakerydemo/tree/master/bakerydemo/breads/migrations
You're on master but don't have that file?

('breads', '0001_initial'),
]

operations = [
migrations.AddField(
model_name='breadsindexpage',
name='image',
field=models.ForeignKey(blank=True, help_text='Location listing image', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='wagtailimages.Image'),
),
migrations.AddField(
model_name='breadsindexpage',
name='introduction',
field=models.TextField(blank=True, help_text='Text to describe the index page'),
),
]
19 changes: 17 additions & 2 deletions bakerydemo/breads/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger



@register_snippet
class Country(models.Model):
"""
Expand Down Expand Up @@ -103,16 +102,32 @@ class BreadsIndexPage(Page):
BreadPage - so that it works as an index page
"""

introduction = models.TextField(
help_text='Text to describe the index page',
blank=True)
image = models.ForeignKey(
'wagtailimages.Image',
null=True,
blank=True,
on_delete=models.SET_NULL,
related_name='+',
help_text='Location listing image'
)
subpage_types = ['BreadPage']

content_panels = Page.content_panels + [
FieldPanel('introduction'),
ImageChooserPanel('image'),
]

def get_context(self, request):
context = super(BreadsIndexPage, self).get_context(request)

# Get the full unpaginated listing of resource pages as a queryset -
# replace this with your own query as appropriate
all_resources = self.get_children().live()

paginator = Paginator(all_resources, 5) # Show 5 resources per page
paginator = Paginator(all_resources, 5) # Show 5 resources per page

page = request.GET.get('page')
try:
Expand Down

0 comments on commit bc54cb4

Please sign in to comment.