django 设置url

nity224 发布于 2014/03/07 09:40
阅读 1K+
收藏 0

大家好,我刚学python。在搭django有个问题。

我用的django版本是1.62,python版本是2.7.6

我是参考这个大神的配置去建博客

http://www.cnblogs.com/cacique/archive/2012/09/29/2707976.html

但是我在admin配置的时候页面提示

A server error occurred.  Please contact the administrator.

cmd窗口提示


 File "c:\Python27\lib\wsgiref\handlers.py", line 85, in run
   self.result = application(self.environ, self.start_response)
 File "c:\Python27\lib\site-packages\django\contrib\staticfiles\handlers.py", l
ne 67, in __call__
   return self.application(environ, start_response)
 File "c:\Python27\lib\site-packages\django\core\handlers\wsgi.py", line 187, i
 __call__
   self.load_middleware()
 File "c:\Python27\lib\site-packages\django\core\handlers\base.py", line 49, in
load_middleware
   mw_instance = mw_class()
 File "c:\Python27\lib\site-packages\django\middleware\locale.py", line 24, in
_init__
   for url_pattern in get_resolver(None).url_patterns:
 File "c:\Python27\lib\site-packages\django\core\urlresolvers.py", line 346, in
url_patterns
   patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
 File "c:\Python27\lib\site-packages\django\core\urlresolvers.py", line 341, in
urlconf_module
   self._urlconf_module = import_module(self.urlconf_name)
 File "c:\Python27\lib\site-packages\django\utils\importlib.py", line 40, in im
ort_module
   __import__(name)
 File "c:\Python27\Django-1.6.2\django\bin\blog\blog\urls.py", line 12, in <mod
le>
   url(r'^admin/doc/',include('django.contrib.admindocs.url')),
 File "c:\Python27\lib\site-packages\django\conf\urls\__init__.py", line 26, in
include
   urlconf_module = import_module(urlconf_module)
 File "c:\Python27\lib\site-packages\django\utils\importlib.py", line 40, in im
ort_module
   __import__(name)
mportError: No module named url

我的url.py设置是这样的

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


from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
    # Examples:
     #url(r'^$', 'blog.views.home', name='home'),
     #url(r'^blog/', include('blog.urls')),
                       
    url(r'^admin/doc/',include('django.contrib.admindocs.url')),
    url(r'^admin/', include(admin.site.urls)),
                
)


问下各位问题出在哪里了?



加载中
0
CheneyWong
CheneyWong
No module named url
0
YueZheng
YueZheng
应该是Django的版本太高了。你试试把django的版本降到1.5以下吧。1.5以上版本的变化还是挺大的。
返回顶部
顶部