python - Django错误{页面未找到,错误404},
问题描述
Using the URLconf defined in project.urls, Django tried
these URL patterns, in this order:
admin/
The current path, polls/, didn't match any of these.
C:\Users\Kwaku Biney\Desktop\dj\mysite\polls\urls.py
from django.urls import path
from . import views
urlpatterns = [
path('', views.index, name='index'),]
C:\Users\Kwaku Biney\Desktop\dj\mysite\mysite\urls.py
from django.contrib import admin
from django.urls import include, path
urlpatterns = [
path('polls/', include('polls.urls')),
path('admin/', admin.site.urls),]
mysite\polls\views.py
from django.shortcuts import render
from django.http import HttpResponse
def index(request):
return HttpResponse("Hello, world. You're at the polls index.")
设置.py
# Application definition
# Application definition
INSTALLED APPS= [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'polls',]
民意调查/apps.py
from django.apps import AppConfig
class PollsConfig(AppConfig):
name = 'polls'
解决方案
问题是我没有保存文件。在 Windows 上的 VSCode 中通过 CTRL + K + S 做到这一点。页
您也可以通过 File => Autosave on Menu Bar 打开 VsCode 上的 AutoSave。
推荐阅读
- java - Gradle clean 无法删除依赖的jar
- json - Swifty JSON:将 JSON 数组中的对象分层列表转换为分层 Swift 对象
- mysql - 选择日期,然后将其放入组中
- sql - 为什么这个 SQL 查询永远运行?
- django - 过滤器 - 如何实现
- excel - WorksheetFunction.SumIfs 基于具有日期和时间的 Range
- eclipse-scout - 从请求中获取 URL 参数
- python - 检查层是否具有 keras CNN 的权重
- python - 如何模拟或单元测试 celery 任务自定义更新
- javascript - Gulp 和 browserify 给出错误:Cannot find module 'jquery' from 'C:....'