viewmustbeacallable or a list/tuple in the caseof include().

"""minicms URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/1.11/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  url(r'^$', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  url(r'^$', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.conf.urls import url, include
    2. Add a URL to urlpatterns:  url(r'^blog/', include('blog.urls'))
"""
from django.conf.urls import url
from django.contrib import admin
#
from django.conf import settings
 
#
from django.conf.urls import include, url
from DjangoUeditor import urls as DjangoUeditor_urls
from news.views import index
from news.views import column_detail
from news.views import article_detail
urlpatterns = [
# 修改 minicms/urls.py 添加上面的規則:
# 首頁 index   欄目 column    文章詳情   article
    #url(r'^blog/', include('blog.urls'))
    url(r'^$', index),
    #url(r'^column/(?P<column_slug>[^/]+)/$', 'news.views.column_detail', name='column'),
    #url(r'^news/(?P<article_slug>[^/]+)/$', 'news.views.article_detail', name='article'),
# 
    #url(r'^ueditor/', include('DjangoUeditor.urls' )),
    #url(r'^admin/', admin.site.urls),

    #url(r'^$', 'news.views.index', name='index'),
    url(r'^column/(?P<column_slug>[^/]+)/$', column_detail),
    url(r'^news/(?P<article_slug>[^/]+)/$', article_detail),
 
    url(r'^admin/', include(admin.site.urls)),
]

if settings.DEBUG:
    from django.conf.urls.static import static
    urlpatterns += static(

        settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
啓動服務器:python manage.py runserver
System check identified no issues (0 silenced).
July 24, 2017 - 20:50:33
Django version 1.11.3, using settings 'minicms.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.

解決方案1:
https://stackoverflow.com/que...
將url(r'^website/$',"website.views.first_page"),寫成url(r'^website/$', website.views.first_page),
解決方案2:
from news import viewspython

news能夠替換爲你新建的app應用名稱,vies.py是在你建立的app應用下的

url(r'^$', index),
    #url(r'^column/(?P<column_slug>[^/]+)/$', news.views.column_detail', name='column'),
    #url(r'^news/(?P<article_slug>[^/]+)/$', news.views.article_detail', name='article'),

寫法改成:web

url(r'^$', views.index, name='index'),
    url(r'^column/(?P<column_slug>[^/]+)/$', views.column_detail, name='column'),
    url(r'^news/(?P<article_slug>[^/]+)/$', views.article_detail, name='article'),

【參考】http://blog.csdn.net/godlikeb...
的寫法django

相關文章
相關標籤/搜索