from django.contrib import admin
from django.urls import path, include
urlpatterns = [
path('', include('sito.urls')),
path('admin/', admin.site.urls),
path('display_config/', include('sito.urls')),
]
djangoprojec/urls.py
from django.urls import path
from sito import views
urlpatterns = [
path('', views.index, name='index'),
path('display_config/', views.display_config, name='display_config'),
]
from django.http import HttpResponse
from django.shortcuts import render
from django.template import loader
from .models import PingAction, Config
from . import views
def index(request):
return HttpResponse("Hello, world.")
def display_config(request):
config_list = Config.objects.all()
template = loader.get_template("display_config.html")
context = {
"config_list": config_list,
}
return HttpResponse(template.render(context, request))
httpd.conf
WSGIScriptAlias /app-web /mnt/data/Workspace/app/app-web/djangoProject/djangoProject/wsgi.py
WSGIPythonHome /mnt/data/Workspace/app/app-web/app-web-env
WSGIPythonPath /mnt/data/Workspace/app/app-web/djangoProject
<Directory "/mnt/data/Workspace/app/app-web/djangoProject">
<Files wsgi.py>
Require all granted
</Files>
</Directory>
当我导航到http:// localhost/app-web/我会变得更正“你好,世界。 “重定向太多”错误。
如果我使用
python manage.py runserver
并导航到Http://127.0.0.1:8000/display_config
都纠正了。
有人可以帮我了解怎么了吗?非常感谢
我认为您有2个URL来(http:// localhost/app-web/display_config) BT在主URL文件中清除此行,可以解决问题 路径('display_config/',include(sito.urls')),