在此服务器nginx djang上找不到URL

2024-10-03 17:16:00 发布

您现在位置:Python中文网/ 问答频道 /正文

当我转到url时,我在获取一个新的Django应用程序时遇到问题。我刚得到一个“找不到请求的URL/spacegame/在这个服务器上找不到”错误。我在应用程序中安装了设置.py,在电源中设置url模式网址.py和应用程序网址.py,并创建了应用程序视图.py. 它在我的Django开发服务器上工作,但不在生产服务器上工作。我想也可能是nginx的设置,但不确定。任何帮助都将不胜感激。应用程序名为“太空游戏”。在

主网址.py在

from django.conf.urls import url, include
from django.contrib import admin

urlpatterns = [
    url(r'^$', include('homepageapp.urls')),
    url(r'^spacegame/', include('spacegame.urls')),
    url(r'^admin/', admin.site.urls)
]

在太空游戏.url.py在

^{pr2}$

在太空游戏.views.py在

from django.shortcuts import render
from django.http import HttpResponse


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

nginx配置

server {
    listen 80;
    server_name ::removed:: ;
    return 301 https://$server_name$request_uri;

    root /home/projects/aar/aarcom;

    location = /favicon.ico {
        access_log off; log_not_found off;
        }

    location / {
        include proxy_params;
        proxy_pass http://unix:/home/projects/aar/aarcom/aarcom.sock;
    }

    location /static {
        allow all;
        alias /home/projects/aar/aarcom/static;
        }

    location ~ /.well-known {
        allow all;
        }
}

Tags: djangofrompyimport服务器应用程序游戏url