English 中文(简体)
Django 辅导问题: 目前的道路,即民意测验,与其中的任何一条相匹配。
原标题:Django tutorial problem: The current path, polls/, didn’t match any of these

我刚刚从Django开始,我对网络发展感到触动,因此,这可能是一件容易的事。 我从正式文件中穿过Django Polls Tutorial,我几乎碰到了一个问题。 I m没有成功访问http:// localhost:8000/polls/。 我收到错误......

Page not found (404) Request Method: GET Request URL: http://localhost:8000/polls/ Using the URLconf defined in mysite.urls, Django tried these URL patterns, in this order:

admin/ The current path, polls/, didn’t match any of these.

我的相关守则......

mysitepollsviews.py

from django.http import HttpResponse


def index(request):
    return HttpResponse("Hello, world. You re at the polls index.")

mysitepollsurls.py

from django.urls import path

from . import views

urlpatterns = [
    path(  , views.index, name= index ),
]

mysiteurls.py

from django.contrib import admin
from django.urls import include, path

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

mysitemysitesetting.py

INSTALLED_APPS = [
     django.contrib.admin ,
     django.contrib.auth ,
     django.contrib.contenttypes ,
     django.contrib.sessions ,
     django.contrib.messages ,
     django.contrib.staticfiles ,
]
ROOT_URLCONF =  mysite.urls 

www.un.org/Depts/DGACM/index_spanish.htm 发展服务器是。

Not Found: /polls/ [06/Dec/2022 15:02:01] "GET /polls/ HTTP/1.1" 404 2095

我曾尝试过我从其他类似的辅导站那里看到的固定装置,但没有任何工作,我感到,我像我一样,在这个黑暗中tab。

Thank you Hash & Carlos for taking a look. I modified as suggested, and restarted server, but I get the exact same result...

mysitedings.py

INSTALLED_APPS = [
     django.contrib.admin ,
     django.contrib.auth ,
     django.contrib.contenttypes ,
     django.contrib.sessions ,
     django.contrib.messages ,
     django.contrib.staticfiles ,
     polls ,
]

我感到,尽管有一条简单的道路错误,却发生了一些how。 我的集延戈是否会有错误? 我确实看到了当地座椅:8000,正如我所应当的那样。

问题回答
INSTALLED_APPS = [
     django.contrib.admin ,
     django.contrib.auth ,
     django.contrib.contenttypes ,
     django.contrib.sessions ,
     django.contrib.messages ,
     django.contrib.staticfiles ,
     polls ,
]

you are written the code correclty but you need to add your apps in intalled apps in settings.py file

我删除了我的项目和我的虚拟环境(因为这是其中唯一的事情),并从零开始。 www.un.org/Depts/DGACM/index_french.htm 我不明白为什么。 在我看来,问题并不明确,但我正在向更大和更好的挑战迈进。 答复的附带条件!

BTW:我不必在环境中增加“生活”。 符合教学法的档案

try change port

py manage.py runserver 8080

它为我工作





相关问题
How to get two random records with Django

How do I get two distinct random records using Django? I ve seen questions about how to get one but I need to get two random records and they must differ.

Moving (very old) Zope/Plone Site to Django

I am ask to move data from a (now offline) site driven by Plone to a new Django site. These are the version informations I have: Zope Version (unreleased version, python 2.1.3 ) Python Version 2.1....

Can Django models use MySQL functions?

Is there a way to force Django models to pass a field to a MySQL function every time the model data is read or loaded? To clarify what I mean in SQL, I want the Django model to produce something like ...

Flexible pagination in Django

I d like to implement pagination such that I can allow the user to choose the number of records per page such as 10, 25, 50 etc. How should I go about this? Is there an app I can add onto my project ...

is it convenient to urlencode all next parameters? - django

While writing code, it is pretty common to request a page with an appended "next" query string argument. For instance, in the following template code next points back to the page the user is on: &...

Pragmatically adding give-aways/freebies to an online store

Our business currently has an online store and recently we ve been offering free specials to our customers. Right now, we simply display the special and give the buyer a notice stating we will add the ...

热门标签