导入非流动对象时出现 django urls 错误
django urls error when I import a non-itinerant object
我不明白为什么在导入我的视图时出现错误。
我不明白错误在哪里。我从项目和视图中删除了一些应用程序,会这样吗?
观看次数
from django.shortcuts import render
from django.views.generic import ListView
from .views import Schede
class SchedeListView(ListView):
model = Schede
template_name = 'test.html'
context_object_name = 'schede'
开发测试urls
from django.urls import path
from django.views.generic import TemplateView
from .views import views
urlpatterns = [
path('', TemplateView.as_view(template_name="dash.html"), name="home"),
path('test_schede/', views.SchedeListView.as_view(), name="test_schede"),
]
url 一般
from django.contrib import admin
from django.urls import path, include
#sitemap
from django.contrib.sitemaps.views import sitemap
from .sitemaps import StaticViewSitemap
#pdf
from pdf.views import testPdfView
sitemaps = {'static': StaticViewSitemap}
urlpatterns = [
path('admin/', admin.site.urls),
path('test/<id>/', testPdfView, name="test_pdf"),
path('sitemap.xml', sitemap, {'sitemaps': sitemaps}),
path('', include('devtest.urls'))
]
错误
C:\Users\dev\Downloads\laragon\www\scheda>python manage.py runserver
Watching for file changes with StatReloader
Performing system checks...
Exception in thread django-main-thread:
Traceback (most recent call last):
File "C:\Users\dev\Downloads\laragon\bin\python\python-3.6.1\lib\site-packages
\django\urls\resolvers.py", line 600, in url_patterns
iter(patterns)
TypeError: 'module' object is not iterable
你的进口商品还好吗?如果 Schede
是一个模型,我相信它应该从 models.py
导入。最好在导入中指定 your_app
名称。
from .views import Schede
也许应该是:
from your_app.models import Schede
另外,你确定这次导入没问题吗?
from .views import views
也许应该是这样的:
from your_app import views
我不明白为什么在导入我的视图时出现错误。 我不明白错误在哪里。我从项目和视图中删除了一些应用程序,会这样吗?
观看次数
from django.shortcuts import render
from django.views.generic import ListView
from .views import Schede
class SchedeListView(ListView):
model = Schede
template_name = 'test.html'
context_object_name = 'schede'
开发测试urls
from django.urls import path
from django.views.generic import TemplateView
from .views import views
urlpatterns = [
path('', TemplateView.as_view(template_name="dash.html"), name="home"),
path('test_schede/', views.SchedeListView.as_view(), name="test_schede"),
]
url 一般
from django.contrib import admin
from django.urls import path, include
#sitemap
from django.contrib.sitemaps.views import sitemap
from .sitemaps import StaticViewSitemap
#pdf
from pdf.views import testPdfView
sitemaps = {'static': StaticViewSitemap}
urlpatterns = [
path('admin/', admin.site.urls),
path('test/<id>/', testPdfView, name="test_pdf"),
path('sitemap.xml', sitemap, {'sitemaps': sitemaps}),
path('', include('devtest.urls'))
]
错误
C:\Users\dev\Downloads\laragon\www\scheda>python manage.py runserver
Watching for file changes with StatReloader
Performing system checks...
Exception in thread django-main-thread:
Traceback (most recent call last):
File "C:\Users\dev\Downloads\laragon\bin\python\python-3.6.1\lib\site-packages
\django\urls\resolvers.py", line 600, in url_patterns
iter(patterns)
TypeError: 'module' object is not iterable
你的进口商品还好吗?如果 Schede
是一个模型,我相信它应该从 models.py
导入。最好在导入中指定 your_app
名称。
from .views import Schede
也许应该是:
from your_app.models import Schede
另外,你确定这次导入没问题吗?
from .views import views
也许应该是这样的:
from your_app import views