实际上我正试图从 posts 文件夹中导入模型,并且出现以下错误。
AttributeError: module 'posts' has no attribute 'views'
这是urls.py
from django.contrib import admin
from django.urls import path
from . import views
from django.conf.urls import include
import accounts
import posts
urlpatterns = [
path('admin/', admin.site.urls),
path('',views.home, name = 'home'),
path('login/',include('accounts.urls')),
path('signup/',accounts.views.signup, name='signup' ),
path('logout/',accounts.views.logout, name='logout'),
path('posts/',posts.views.myposts)
]
这是我的帖子文件夹
这是我的posts.views
from django.shortcuts import render, HttpResponse
# Create your views here.
def myposts(request):
return HttpResponse('all_post.html')