Django面包店ImportError:无法导入' p'。路径必须完全合格

时间:2018-02-22 19:26:28

标签: python django django-bakery

我试图用django面包店将我的网站导出为平面文件。

我使用示例民意调查应用创建了一个虚拟网站,当我运行ti-nspire

时出现此错误
python manage.py build

我正确地遵循了所有指示:

轮询/ views.py:

  File "python3.6/site-packages/bakery/management/commands/build.py", line 112, in handle
    self.build_views()
  File "python3.6/site-packages/bakery/management/commands/build.py", line 240, in build_views
    view = get_callable(view_str)
  File "python3.6/site-packages/django/urls/utils.py", line 25, in get_callable
    raise ImportError("Could not import '%s'. The path must be fully qualified." % lookup_view)
ImportError: Could not import 'p'. The path must be fully qualified.

settings.py:

from bakery.views import BuildableTemplateView

class HomePageView(BuildableTemplateView):

    template_name = "home.html"
    build_path = 'index.html'
    def get_context_data(self, **kwargs):
        context = super().get_context_data(**kwargs)
        return context

的mysite / urls.py:

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'polls',
    'bakery'
]
BUILD_DIR = '/Users/me/Downloads/build/'

BAKERY_VIEWS = (
    'polls.views.HomePageView'
)

轮询/ urls.py:

urlpatterns = [
    path('admin/', admin.site.urls),
    path('polls/', include('polls.urls')),
]

也许它与网址有关?但是,我无法看到什么。该网站在浏览器中正常工作......

1 个答案:

答案 0 :(得分:2)

我怀疑这是因为设置应该是一个元组,需要一个逗号。

BAKERY_VIEWS = (
    'polls.views.HomePageView',
)