使用Django设置/Django/path fromhttp://localhost/Django/

2024-05-08 01:14:50 发布

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

我的Apache2 virtualhost配置中有这个WSGIScriptAlias/django//path/to/app。你知道吗

我使用django admin startproject myapp创建了这个项目。 但是当我转到http://localhost/django/时,我通过Django得到一个404错误 如果我将virtualhost配置更改为just/并重新启动apache2。它可以工作,但我将其用于其他事情,因此需要使用virtualhost和/django/sub路径。但看起来Django的工作方式并不正确。你知道吗

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

    ^admin/
    The empty path didn't match any of these.
    You're seeing this error because you have DEBUG = True in your 
    Django settings file. Change that to False, and Django will 
    display a standard 404 page.

我猜在运行django admin startproject时,它希望应用程序以默认URL运行,即http://localhost/没有子路径?你知道吗

我需要编辑吗网址.py或者设置.py使用/django/?你知道吗


Tags: topathdjangoin路径localhosthttpurl