我在Django遇到過很多問題(並非所有問題都解決了),但這是迄今爲止最奇怪,最不可理解的問題。無法理解的Django Runserver錯誤
>python manage.py runserver Validating models... 0 errors found Django version 1.3.1, using settings 'ponysite.settings' Development server is running at http://127.0.0.1:8000/ Quit the server with CTRL-BREAK. [01/Nov/2011 01:21:49] "GET/HTTP/1.0" 500 102747 Traceback (most recent call last): File "C:\Python27\lib\site-packages\django\core\servers\basehttp.py", line 284, in run self.finish_response() File "C:\Python27\lib\site-packages\django\core\servers\basehttp.py", line 324, in finish_response self.write(data) File "C:\Python27\lib\site-packages\django\core\servers\basehttp.py", line 420, in write self._write(data) File "C:\Python27\lib\socket.py", line 324, in write self.flush() File "C:\Python27\lib\socket.py", line 303, in flush self._sock.sendall(view[write_offset:write_offset+buffer_size]) error: [Errno 10054] An existing connection was forcibly closed by the remote host ---------------------------------------- Exception happened during processing of request from ('127.0.0.1', 63095) Traceback (most recent call last): File "C:\Python27\lib\SocketServer.py", line 284, in _handle_request_noblock self.process_request(request, client_address) File "C:\Python27\lib\SocketServer.py", line 310, in process_request self.finish_request(request, client_address) File "C:\Python27\lib\SocketServer.py", line 323, in finish_request self.RequestHandlerClass(request, client_address, self) File "C:\Python27\lib\site-packages\django\core\servers\basehttp.py", line 570, in __init__ BaseHTTPRequestHandler.__init__(self, *args, **kwargs) File "C:\Python27\lib\SocketServer.py", line 641, in __init__ self.finish() File "C:\Python27\lib\SocketServer.py", line 694, in finish self.wfile.flush() File "C:\Python27\lib\socket.py", line 303, in flush self._sock.sendall(view[write_offset:write_offset+buffer_size]) error: [Errno 10054] An existing connection was forcibly closed by the remote host ---------------------------------------- Traceback (most recent call last): File "C:\Python27\lib\site-packages\django\core\servers\basehttp.py", line 284, in run self.finish_response() File "C:\Python27\lib\site-packages\django\core\servers\basehttp.py", line 324, in finish_response self.write(data) File "C:\Python27\lib\site-packages\django\core\servers\basehttp.py", line 420, in write self._write(data) File "C:\Python27\lib\socket.py", line 324, in write self.flush() File "C:\Python27\lib\socket.py", line 303, in flush self._sock.sendall(view[write_offset:write_offset+buffer_size]) error: [Errno 10054] An existing connection was forcibly closed by the remote host ---------------------------------------- Exception happened during processing of request from ('127.0.0.1', 63099) Traceback (most recent call last): File "C:\Python27\lib\SocketServer.py", line 284, in _handle_request_noblock self.process_request(request, client_address) File "C:\Python27\lib\SocketServer.py", line 310, in process_request self.finish_request(request, client_address) File "C:\Python27\lib\SocketServer.py", line 323, in finish_request self.RequestHandlerClass(request, client_address, self) File "C:\Python27\lib\site-packages\django\core\servers\basehttp.py", line 570, in __init__ BaseHTTPRequestHandler.__init__(self, *args, **kwargs) File "C:\Python27\lib\SocketServer.py", line 641, in __init__ self.finish() File "C:\Python27\lib\SocketServer.py", line 694, in finish self.wfile.flush() File "C:\Python27\lib\socket.py", line 303, in flush self._sock.sendall(view[write_offset:write_offset+buffer_size]) error: [Errno 10054] An existing connection was forcibly closed by the remote host ---------------------------------------- [01/Nov/2011 01:21:53] "GET/HTTP/1.0" 500 102391
我試圖擦拭和重新創建數據庫,剝離下來views.py
和models.py
到最低限度無濟於事:當我打開一個網頁它發生。我也嘗試在另一臺計算機上運行相同的項目,結果相同。兩者都運行Windows x64。實際上,我認爲一臺電腦運行的是Django 1.3.x和1.2.x,但不管怎樣,這個錯誤看起來都是一樣的。
以下是完整的回溯:
Environment: Request Method: GET Request URL: http://127.0.0.1:8000/ Django Version: 1.3.1 Python Version: 2.7.2 Installed Applications: ['django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.messages', 'django.contrib.staticfiles', 'django.contrib.admin', 'django.contrib.admindocs', 'forum', 'django.contrib.markup'] Installed Middleware: ('django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware') Traceback: File "C:\Python27\lib\site-packages\django\core\handlers\base.py" in get_response 101. request.path_info) File "C:\Python27\lib\site-packages\django\core\urlresolvers.py" in resolve 250. for pattern in self.url_patterns: File "C:\Python27\lib\site-packages\django\core\urlresolvers.py" in _get_url_patterns 279. patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module) File "C:\Python27\lib\site-packages\django\core\urlresolvers.py" in _get_urlconf_module 274. self._urlconf_module = import_module(self.urlconf_name) File "C:\Python27\lib\site-packages\django\utils\importlib.py" in import_module 35. __import__(name) File "C:\Users\kiwi\Dropbox\Programming Projects\Django Projects\ponysite\..\ponysite\urls.py" in 3. admin.autodiscover() File "C:\Python27\lib\site-packages\django\contrib\admin\__init__.py" in autodiscover 26. import_module('%s.admin' % app) File "C:\Python27\lib\site-packages\django\utils\importlib.py" in import_module 35. __import__(name) File "C:\Users\kiwi\Dropbox\Programming Projects\Django Projects\ponysite\forum\admin.py" in 1. from forum.models import Category, Thread, Post, Report, Subscription, Ban Exception Type: ImportError at/ Exception Value: cannot import name Ban
Ban
在models.py
一個模型(views.py
進口),我用了一段時間發揮各地,但目前在我的模型,視圖註釋掉隨處可見,控制器。我不知道它是否與這個問題有任何關係。
在此先感謝,夥計們。
嗯,這說你沒有在論壇/ models.py中定義班班。 你可以仔細檢查一下。 – Lachezar