【问题标题】:Page not found (404) error on company code that I just cloned and should work. Is there anything wrong with the code?我刚刚克隆的公司代码上的页面未找到(404)错误应该可以工作。代码有什么问题吗?
【发布时间】:2019-04-24 17:10:40
【问题描述】:

当我们从存储库克隆 Central Desk 网站时,我和一位同事遇到了同样的问题。它给了我们找不到页面(404)错误,我们不知道为什么。考虑到它是我们网站的代码,该代码应该可以正常工作。

我已尝试将它连接到我们的 VPN 并未连接,我已重新启动克隆过程并重做所有操作,但仍然出现错误。我试过让 Redis 处于保护模式并退出,但没有任何效果。我查看了我们的 urls.py 文件和 settings_development.py 文件,它们看起来都不错。

from django.conf.urls import include, url
from django.views.generic import RedirectView
from django.core.urlresolvers import reverse_lazy
from django.contrib.auth.views import logout_then_login

from heart.views import DashBoard, get_names
from heart.forms import LoginForm
from heart.login import login_set_desk
# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()

urlpatterns =[
        # Examples:
        # url(r'^apps/central_desk/$', 'centraldesk.views.home', name='home'),
        # url(r'^apps/central_desk/centraldesk/', include('centraldesk.foo.urls')),

        # Uncomment the admin/doc line below to enable admin documentation:
        # url(r'^apps/central_desk/admin/doc/', include('django.contrib.admindocs.urls')),

        # Uncomment the next line to enable the admin:
        url(r'^apps/centraldesk/helm/', include(admin.site.urls)),
        url(r'^apps/centraldesk/heart/', include('heart.urls')),
        url(r'^apps/centraldesk/items/', include('item_tracker.urls')),
        url(r'^apps/centraldesk/lost_and_found/', include('lost_and_found.urls')),
        url(r'^apps/centraldesk/mail/', include('mail.urls')),
        url(r'^apps/centraldesk/login/$', login_set_desk, name="login"),
        url(r'^apps/centraldesk/dashboard/$', DashBoard.as_view(), name="dashboard"),
        url(r'^apps/centraldesk/logout/$', logout_then_login, name="logout"),
        url(r'^apps/centraldesk/forum/', include('forums.urls', namespace='forums')),
        url(r'^apps/centraldesk/comm/', include('comm_log.urls')),
        url(r'^apps/centraldesk/checkin/', include('checkin.urls')),
        url(r'^apps/centraldesk/residents/', get_names ),
        url(r'^apps/centraldesk/$', RedirectView.as_view(url=reverse_lazy('dashboard'), permanent=True)),
        url(r'^apps/centraldesk/cash_drawer/', include('cash_drawer.urls')),
        url(r'^apps/centraldesk/reports/', include('reports.urls')),
        url(r'^apps/centraldesk/feedback/', include('feedback.urls')),

]

from .settings_general import *

# debug value is referenced in mail/models.py to determine whether the mailer send function is called.
DEBUG = True

AUTHENTICATION_BACKENDS = (
    'techops.django_auth.backends.ActiveDirectoryBackend',
    'django.contrib.auth.backends.ModelBackend',
)

"""Emails are sent with mail creation. It's found in mail/models.py."""
SEND_EMAILS = False

REDIS_HOST = "127.0.0.1"
REDIS_NAMES_DB = 9

DATABASES = {
    'default': {
        'ENGINE'  : 'django.db.backends.postgresql_psycopg2', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
        'NAME'    : 'vagrant',                      # Or path to database file if using sqlite3.
        'USER'    : 'vagrant',                      # Not used with sqlite3.
        'PASSWORD': 'vagrant',                  # Not used with sqlite3.
        'HOST'    : '127.0.0.1',                      # Set to empty string for localhost. Not used with sqlite3.
        'PORT'    : '',                      # Set to empty string for default. Not used with sqlite3.
    }
}

# Absolute filesystem path to the directory that will hold user-uploaded files.
# Example: "/home/media/media.lawrence.com/media/"

MEDIA_ROOT = os.path.normpath(os.path.join(SITE_ROOT, 'media'))

# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash.
# Examples: "http://media.lawrence.com/media/", "http://example.com/media/"
MEDIA_URL = '/media/'

# URL prefix for static files.
# Example: "http://media.lawrence.com/static/"
STATIC_URL = '/static/'
# Absolute path to the directory static files should be collected to.
# Don't put anything in this directory yourself; store your static files
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
STATIC_ROOT = os.path.normpath(os.path.join(os.path.dirname(__file__), '../static/'))

上面首先是 urls.py 文件,其次是 settings_development.py 文件。我们只是希望能够到达预期的页面。

【问题讨论】:

  • 告诉我们您尝试访问的 URL,并向我们展示 Django 错误页面。
  • @JohnGordon 我只是试图在 127.0.0.1:8000 访问本地主机,它只是 404 错误,它告诉我它在哪里探索以尝试找到该页面。我最终想通了,所以非常感谢您的快速回复!我真的很感激:)

标签: python django url localhost


【解决方案1】:

没关系!对于那些想知道,在本地主机上进行编辑的人,我们在主机上有一个用于 Central Desk 的应用程序,所以它的 URL 是: 127.0.0.1:8000/apps/centraldesk

至少这是我猜测我们为什么要访问那个 URL 的最佳机会。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-09-17
    • 1970-01-01
    • 2021-10-18
    • 1970-01-01
    • 2023-04-01
    • 2015-11-01
    • 2018-12-26
    相关资源
    最近更新 更多