8

基本上我一直在关注本教程,但是在让管理页面工作时我被卡住了。我得到的错误是:在此服务器上找不到请求的 URL /admin/。因此,我查看了很多论坛和很多 stackoverflow 问题,但由于我是一个完整的菜鸟,我不理解其中的一半,而另一半的解决方案并不能解决我的问题。这就是我的 settings.py 的样子:

INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    # Uncomment the next line to enable the admin:
    'django.contrib.admin',
    # Uncomment the next line to enable admin documentation:
    'django.contrib.admindocs',
    'polls'
)

这就是我的 urls.py 的样子:

from django.conf.urls import patterns, include, url


# Uncomment the next two lines to enable the admin:

from django.contrib import admin

admin.autodiscover()


urlpatterns = patterns('',
    # Examples:
    # url(r'^$', 'BoE.views.home', name='home'),
    # url(r'^BoE/', include('BoE.foo.urls')),

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

    # Uncomment the next line to enable the admin:
    url(r'^admin/', include(admin.site.urls)),
)

任何帮助都感激不尽。提前致谢!

4

2 回答 2

6

当您访问 http://127 0 0 1:8000 时,您是否获得了“欢迎使用 Django”页面?(带点)

你要去 http://127 0 0 1:8000/admin/ 吗?

教程第一部分的所有内容都有效吗?您看到数据库中的项目了吗?


在下面的评论中,我们认为问题不在于 Django,因为他的代码与我的代码完全相同(而且我的代码也有效)。他必须去 wiki.bitnami.org/Components/Django 并按照那里的说明进行操作

于 2012-07-20T16:41:59.853 回答
1

我将继续进行尝试,因为这是我能想到的唯一可能仍然是问题的事情。

如果你只运行python manage.py runserver开发服务器绑定到 127.0.0.1:8000。但是,除非您在机器上的浏览器中运行,或者通过机器直接访问它(X Window、VNC、隧道等),否则您无法远程访问它。

如果要以实际 IP 地址访问开发服务器,则需要告诉它绑定到主接口:

python manage.py runserver 0.0.0.0:8000

然后,您将能够在本地浏览器中访问您的网站http://<ip>:8000/admin/

于 2012-07-20T16:55:57.907 回答