简体   繁体   English

我无法在 Django 框架中打开管理页面

[英]I am not able to open admin page in Django Framework

I am trying to build a web app using the Django Framework.我正在尝试使用 Django 框架构建 web 应用程序。 When, I go into localhost:8000/admin the browser says: Firefox can't establish a connection to the server at 127.0.0.1:8000.当我 go 进入 localhost:8000/admin 时,浏览器显示:Firefox 无法在 127.0.0.1:8000 建立与服务器的连接。

I am using PyCharm:我正在使用 PyCharm:

This is the error that comes up in the terminal:这是终端中出现的错误:

Not Found: /未找到: /

[21/Apr/2020 15:18:20] "GET / HTTP/1.1" 404 2031 Following which the server cuts off [21/Apr/2020 15:18:20] "GET / HTTP/1.1" 404 2031 随后服务器中断

my app/urls:我的应用程序/网址:

from django.urls import path
from . import views


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

And my project/urls:还有我的项目/网址:

from django.contrib import admin from django.urls import path, include from django.contrib import admin from django.urls 导入路径,包括

urlpatterns = [
    path('admin/', admin.site.urls),
    path('KMIO_page/', include('KMIO_app1.urls')),
]

In your logs, it says that you visited the home ( "/" ) path, not the path for your admin ( "/admin" ).在您的日志中,它说您访问了路径( "/" ),而不是您的管理员路径( "/admin" )。 The urls.py files seem to be good. urls.py文件似乎很好。 However, you could add in your app/urls.py file, outside of the urlpatterns variable, the variable app_name and assign it the value of KMIO_app1 or the name of your app.但是,您可以在您的app/urls.py文件中,在urlpatterns变量之外添加变量app_name并为其分配KMIO_app1的值或您的应用程序的名称。 Last but not least, you could add in your app/urls.py file a slash ( "/" ) for your home directory.最后但同样重要的是,您可以在您的app/urls.py文件中为您的主目录添加一个斜杠"/" )。 For example:例如:

app/urls.py

from django.urls import path
from . import views


urlpatterns = [
    path('/', views.index),
]

I hope that helps.我希望这会有所帮助。 Please let me know if that fixes your issue.请让我知道这是否能解决您的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我无法在 Django 中访问我的管理员 - I am not able to access my admin in Django 我无法在 Django Admin 中导出 CSV 文件中的图像 - I am not able to export image in CSV file in Django Admin 我无法从 Django 框架中解决 RecursionError - I am not able to resolve the RecursionError from Django framework 无法验证超级用户或登录Django的管理站点,我做错了什么? - Not able to authenticate superuser or login into admin site in Django, what am I doing wrong? 我能创建一个无需登录管理面板即可添加新的django.contrib.auth用户的表单吗? - Am I able to create a form that is able to add a new django.contrib.auth User without logging in to the admin panel? Django Admin Million Data - 管理页面打开时间过长 - Django Admin Million Data - Admin page takes too long to open "为什么在使用 Heroku 部署 Django 时出现内部服务器错误(管理页面仍然有效)?" - Why am I getting an internal server error when deploying Django with Heroku (admin page still works)? 我无法使用Django连接到数据库 - I am not able to connect to the database using django 我无法在 Django 中链接页面 - I am not able to link pages in Django 有谁能够帮助我。 我被困在 Django 无法显示请求的页面的这一步 - can anybody help me. I am stuck at this step where Django is not able to show requested page
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM