# Buggy code
def to_representation(self, page):
    name = page.specific_class._meta.app_label + "." + page.specific_class.__name__
    self.context["view"].seen_types[name] = page.specific_class
    return name


# Traceback (AttributeError)
Internal Server Error: /admin/api/v2beta/pages/
Traceback (most recent call last):
File "/home/vagrant/.virtualenvs/bakerydemo/lib/python3.4/site-packages/django/core/handlers/exception.py", line 35, in inner
response = get_response(request)
File "/home/vagrant/.virtualenvs/bakerydemo/lib/python3.4/site-packages/django/core/handlers/base.py", line 128, in _get_response
response = self.process_exception_by_middleware(e, request)
File "/home/vagrant/.virtualenvs/bakerydemo/lib/python3.4/site-packages/django/core/handlers/base.py", line 126, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/vagrant/.virtualenvs/bakerydemo/lib/python3.4/site-packages/django/views/decorators/cache.py", line 31, in _cache_controlled
response = viewfunc(request, *args, **kw)
File "/vagrant/wagtail/wagtail/admin/urls/__init__.py", line 102, in wrapper
return view_func(request, *args, **kwargs)
File "/vagrant/wagtail/wagtail/admin/decorators.py", line 34, in decorated_view
return view_func(request, *args, **kwargs)
File "/vagrant/wagtail/wagtail/api/v2/router.py", line 63, in wrapped
return func(request, *args, **kwargs)
File "/home/vagrant/.virtualenvs/bakerydemo/lib/python3.4/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view
return view_func(*args, **kwargs)
File "/home/vagrant/.virtualenvs/bakerydemo/lib/python3.4/site-packages/rest_framework/viewsets.py", line 95, in view
return self.dispatch(request, *args, **kwargs)
File "/home/vagrant/.virtualenvs/bakerydemo/lib/python3.4/site-packages/rest_framework/views.py", line 494, in dispatch
response = self.handle_exception(exc)
File "/vagrant/wagtail/wagtail/api/v2/endpoints.py", line 116, in handle_exception
return super().handle_exception(exc)
File "/home/vagrant/.virtualenvs/bakerydemo/lib/python3.4/site-packages/rest_framework/views.py", line 454, in handle_exception
self.raise_uncaught_exception(exc)
File "/home/vagrant/.virtualenvs/bakerydemo/lib/python3.4/site-packages/rest_framework/views.py", line 491, in dispatch
response = handler(request, *args, **kwargs)
File "/vagrant/wagtail/wagtail/admin/api/endpoints.py", line 94, in listing_view
response = super().listing_view(request)
File "/vagrant/wagtail/wagtail/api/v2/endpoints.py", line 74, in listing_view
return self.get_paginated_response(serializer.data)
File "/home/vagrant/.virtualenvs/bakerydemo/lib/python3.4/site-packages/rest_framework/serializers.py", line 742, in data
ret = super(ListSerializer, self).data
File "/home/vagrant/.virtualenvs/bakerydemo/lib/python3.4/site-packages/rest_framework/serializers.py", line 262, in data
self._data = self.to_representation(self.instance)
File "/home/vagrant/.virtualenvs/bakerydemo/lib/python3.4/site-packages/rest_framework/serializers.py", line 660, in to_representation
self.child.to_representation(item) for item in iterable
File "/home/vagrant/.virtualenvs/bakerydemo/lib/python3.4/site-packages/rest_framework/serializers.py", line 660, in <listcomp>
self.child.to_representation(item) for item in iterable
File "/vagrant/wagtail/wagtail/api/v2/serializers.py", line 275, in to_representation
meta[field.field_name] = field.to_representation(attribute)
File "/vagrant/wagtail/wagtail/api/v2/serializers.py", line 82, in to_representation
name = page.specific_class._meta.app_label + '.' + page.specific_class.__name__
AttributeError: 'NoneType' object has no attribute '_meta'

# Fixed code
def to_representation(self, page):
    if page.specific_class is None:
        return None
    name = page.specific_class._meta.app_label + "." + page.specific_class.__name__
    self.context["view"].seen_types[name] = page.specific_class
    return name