nephila / djangocms-rest-view

A REST interface to django CMS
BSD 3-Clause "New" or "Revised" License
11 stars 4 forks source link

Reverse for 'page-detail' not found #8

Open marksweb opened 6 years ago

marksweb commented 6 years ago

Just trying to get the app setup to see if it meets some requirements for a project & I'm seeing reverse('page-detail', args=(obj.pk,)) from the navigation & page serializers.

Is this URL expected in CMS & perhaps existed in an older version of CMS?

I'm using;

Django==1.11.14
django-cms==3.4.6
djangocms-rest-view==0.1.9
djangorestframework==3.4.7

Full traceback

Internal Server Error: /en/api/pages/menu/
Traceback (most recent call last):
  File "/Users/mwalker/Sites/cms-rest/lib/python2.7/site-packages/django/core/handlers/exception.py", line 41, in inner
    response = get_response(request)
  File "/Users/mwalker/Sites/cms-rest/lib/python2.7/site-packages/django/core/handlers/base.py", line 187, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/Users/mwalker/Sites/cms-rest/lib/python2.7/site-packages/django/core/handlers/base.py", line 185, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/Users/mwalker/Sites/cms-rest/lib/python2.7/site-packages/django/views/decorators/csrf.py", line 58, in wrapped_view
    return view_func(*args, **kwargs)
  File "/Users/mwalker/Sites/cms-rest/lib/python2.7/site-packages/rest_framework/viewsets.py", line 87, in view
    return self.dispatch(request, *args, **kwargs)
  File "/Users/mwalker/Sites/cms-rest/lib/python2.7/site-packages/rest_framework/views.py", line 474, in dispatch
    response = self.handle_exception(exc)
  File "/Users/mwalker/Sites/cms-rest/lib/python2.7/site-packages/rest_framework/views.py", line 434, in handle_exception
    self.raise_uncaught_exception(exc)
  File "/Users/mwalker/Sites/cms-rest/lib/python2.7/site-packages/rest_framework/views.py", line 471, in dispatch
    response = handler(request, *args, **kwargs)
  File "/Users/mwalker/Sites/cms-rest/lib/python2.7/site-packages/djangocms_rest_view/views.py", line 64, in menu
    return Response(serializer.data)
  File "/Users/mwalker/Sites/cms-rest/lib/python2.7/site-packages/rest_framework/serializers.py", line 701, in data
    ret = super(ListSerializer, self).data
  File "/Users/mwalker/Sites/cms-rest/lib/python2.7/site-packages/rest_framework/serializers.py", line 240, in data
    self._data = self.to_representation(self.instance)
  File "/Users/mwalker/Sites/cms-rest/lib/python2.7/site-packages/rest_framework/serializers.py", line 619, in to_representation
    self.child.to_representation(item) for item in iterable
  File "/Users/mwalker/Sites/cms-rest/lib/python2.7/site-packages/rest_framework/serializers.py", line 477, in to_representation
    ret[field.field_name] = field.to_representation(attribute)
  File "/Users/mwalker/Sites/cms-rest/lib/python2.7/site-packages/rest_framework/fields.py", line 1679, in to_representation
    return method(value)
  File "/Users/mwalker/Sites/cms-rest/lib/python2.7/site-packages/djangocms_rest_view/serializers.py", line 41, in get_url
    return reverse('page-detail', args=(obj.id,))
  File "/Users/mwalker/Sites/cms-rest/lib/python2.7/site-packages/django/urls/base.py", line 91, in reverse
    return force_text(iri_to_uri(resolver._reverse_with_prefix(view, prefix, *args, **kwargs)))
  File "/Users/mwalker/Sites/cms-rest/lib/python2.7/site-packages/django/urls/resolvers.py", line 497, in _reverse_with_prefix
    raise NoReverseMatch(msg)
NoReverseMatch: Reverse for 'page-detail' not found. 'page-detail' is not a valid view function or pattern name.
[10/Jul/2018 23:11:25] "GET /en/api/pages/menu/ HTTP/1.1" 500 21031
yakky commented 6 years ago

page-detail is the fundamental django cms view and hasn't changed in ages. Could you post INSTALLED_APPS and urls.py? Is plain django CMS working nicely in the "boring" way?

marksweb commented 6 years ago

@yakky Yeah the CMS works just fine. I set up a demo project with divio's api & react app then installed this app on that project after you told me about it last night. I'm trying to get the two setup in the same project so I can compare them to see what approach we may be able to take.

I couldn't find the page-detail URL/view while searching CMS so wondered if something had changed - I'm not as knowledgable about the internals as I'd like to be.

INSTALLED_APPS = [
    'djangocms_admin_style',
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.sitemaps',
    'django.contrib.staticfiles',
    'django.contrib.messages',
    'cms',
    'menus',
    'sekizai',
    'treebeard',
    'djangocms_text_ckeditor',
    'djangocms_style',
    'djangocms_column',
    'filer',
    'easy_thumbnails',
    'cmsplugin_filer_image',
    'cmsplugin_filer_file',
    'cmsplugin_filer_folder',
    'cmsplugin_filer_teaser',
    'cmsplugin_filer_utils',
    'cmsplugin_filer_video',
    'djangocms_googlemap',
    'djangocms_inherit',
    'djangocms_link',
    # 'reversion',
    'example_site',
    'plugins',
    'rest_framework',
    # 'djangocms_rest_api',
    'djangocms_rest_view',
    'djangocms_rest_view.client',
    'corsheaders',
]
# -*- coding: utf-8 -*-
from __future__ import absolute_import, print_function, unicode_literals

from django.conf import settings
from django.conf.urls import include, url
from django.conf.urls.i18n import i18n_patterns
from django.contrib import admin
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
from django.contrib.sitemaps.views import sitemap
from django.views.static import serve
from cms.sitemaps import CMSSitemap

admin.autodiscover()

urlpatterns = [
    url(r'^sitemap\.xml$', sitemap,
        {'sitemaps': {'cmspages': CMSSitemap}}),
    url(r'^select2/', include('django_select2.urls')),
]

urlpatterns += i18n_patterns(
    url(r'^admin/', admin.site.urls),
    # url(r'^api/', include('djangocms_rest_api.urls', namespace='api')),
    url(r'^api/', include('djangocms_rest_view.urls', namespace='api')),
    url(r'^rest/', include('djangocms_rest_view.client.urls')),
    url(r'^', include('cms.urls')),
)

# This is only needed when using runserver.
if settings.DEBUG:
    urlpatterns = [
        url(r'^media/(?P<path>.*)$', serve,  # NOQA
            {'document_root': settings.MEDIA_ROOT, 'show_indexes': True}),
        ] + staticfiles_urlpatterns() + urlpatterns  # NOQA
yakky commented 6 years ago

:thinking: