from django.http import Http404
from django.core.exceptions import PermissionDenied
from django.views.generic import DetailView, TemplateView, UpdateView

from wafer.pages.models import Page
from wafer.pages.forms import PageForm


class ShowPage(DetailView):
    template_name = 'wafer.pages/page.html'
    model = Page


class EditPage(UpdateView):
    template_name = 'wafer.pages/page_form.html'
    model = Page
    form_class = PageForm
    fields = ['name', 'content']


def slug(request, url):
    """Look up a page by url (which is a tree of slugs)"""
    page = None
    for slug in url.split('/'):
        if not slug:
            continue
        try:
            page = Page.objects.get(slug=slug, parent=page)
        except Page.DoesNotExist:
            raise Http404

    if page is None:
        try:
            page = Page.objects.get(slug='index')
        except Page.DoesNotExist:
            return TemplateView.as_view(
                template_name='wafer/index.html')(request)

    if 'edit' in request.GET.keys():
        if not request.user.has_perm('pages.change_page'):
            raise PermissionDenied
        return EditPage.as_view()(request, pk=page.id)

    return ShowPage.as_view()(request, pk=page.id)

wafer/pages/views.py
from django.http import Http404
from django.core.exceptions import PermissionDenied
from django.views.generic import DetailView, TemplateView, UpdateView

from wafer.pages.models import Page
from wafer.pages.forms import PageForm


class ShowPage(DetailView):
    template_name = 'wafer.pages/page.html'
    model = Page


class EditPage(UpdateView):
    template_name = 'wafer.pages/page_form.html'
    model = Page
    form_class = PageForm


def slug(request, url):
    """Look up a page by url (which is a tree of slugs)"""
    page = None
    for slug in url.split('/'):
        if not slug:
            continue
        try:
            page = Page.objects.get(slug=slug, parent=page)
        except Page.DoesNotExist:
            raise Http404

    if page is None:
        try:
            page = Page.objects.get(slug='index')
        except Page.DoesNotExist:
            return TemplateView.as_view(
                template_name='wafer/index.html')(request)

    if 'edit' in request.GET.keys():
        if not request.user.has_perm('pages.change_page'):
            raise PermissionDenied
        return EditPage.as_view()(request, pk=page.id)

    return ShowPage.as_view()(request, pk=page.id)

wafer/pages/views.py
diff --git a/wafer/pages/views.py b/wafer/pages/views.py
index 70dd7fb1..fee10798 100644
--- a/wafer/pages/views.py
+++ b/wafer/pages/views.py
@@ -15,7 +15,6 @@ class EditPage(UpdateView):
     template_name = 'wafer.pages/page_form.html'
     model = Page
     form_class = PageForm
-    fields = ['name', 'content']
 
 
 def slug(request, url):

Wafer page editing fails on Django 1.8 with ImproperlyConfigured: error
As seen on Travis, and confirmed locally, attempting to edit a page bombs out, ending with

"Specifying both 'fields' and 'form_class' is not permitted."
ImproperlyConfigured: Specifying both 'fields' and 'form_class' is not permitted.

