Strange tutorial behavior...

4 views
Skip to first unread message

Jon

unread,
Apr 17, 2008, 11:46:59 AM4/17/08
to Django users
I successfully ran the complete tutorial (using version 0.96.1) on my
home machine over last weekend without incident.

This week, I tried to bring up my new application at work and started
getting some strange errors in the admin tool. So I went back and
redid the tutorial (to see if I was doing anything different in my own
app that I could understand) and I got the same weird errors (which is
diffferent from what I got when I did this on my home machine - both
are Windows XP, one is Home, one is Office, and the home machine is on
Python 2.4 whereas the office machine is on Python 2.5 - those are the
only differences).

When I try to open the Polls table in the admin tool (which has the
Date/Time), I get the following traceback:

Django version 0.96.1, using settings 'mysite.settings'
Development server is running at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
[17/Apr/2008 11:37:11] "GET /admin/ HTTP/1.1" 200 5199
[17/Apr/2008 11:37:16] "GET /admin/polls/choice/ HTTP/1.1" 200 1445
[17/Apr/2008 11:37:19] "GET /admin/polls/choice/add/ HTTP/1.1" 200
3014
[17/Apr/2008 11:37:19] "GET /admin/jsi18n/ HTTP/1.1" 200 801
[17/Apr/2008 11:37:29] "GET /admin/ HTTP/1.1" 200 5199
[17/Apr/2008 11:37:30] "GET /admin/polls/poll/ HTTP/1.1" 200 1435
[17/Apr/2008 11:37:32] "GET /admin/polls/poll/add/ HTTP/1.1" 200 2881
[17/Apr/2008 11:37:32] "GET /admin/jsi18n/ HTTP/1.1" 200 801
Traceback (most recent call last):
File "C:\Python25\Lib\site-packages\django\core\servers
\basehttp.py", line 273, in run
self.finish_response()
File "C:\Python25\Lib\site-packages\django\core\servers
\basehttp.py", line 312, in finish_response
self.write(data)
File "C:\Python25\Lib\site-packages\django\core\servers
\basehttp.py", line 391, in write
self.send_headers()
File "C:\Python25\Lib\site-packages\django\core\servers
\basehttp.py", line 443, in send_headers
self.send_preamble()
File "C:\Python25\Lib\site-packages\django\core\servers
\basehttp.py", line 370, in send_preamble
self._write('HTTP/%s %s\r\n' % (self.http_version,self.status))
File "C:\Python25\Lib\site-packages\django\core\servers
\basehttp.py", line 487, in _write
self.stdout.write(data)
File "C:\Python25\lib\socket.py", line 262, in write
self.flush()
File "C:\Python25\lib\socket.py", line 249, in flush
self._sock.sendall(buffer)
error: (10054, 'Connection reset by peer')
Traceback (most recent call last):
File "C:\Python25\Lib\site-packages\django\core\servers
\basehttp.py", line 273, in run
self.finish_response()
File "C:\Python25\Lib\site-packages\django\core\servers
\basehttp.py", line 312, in finish_response
self.write(data)
File "C:\Python25\Lib\site-packages\django\core\servers
\basehttp.py", line 391, in write
self.send_headers()
File "C:\Python25\Lib\site-packages\django\core\servers
\basehttp.py", line 443, in send_headers
self.send_preamble()
File "C:\Python25\Lib\site-packages\django\core\servers
\basehttp.py", line 373, in send_preamble
'Date: %s\r\n' % time.asctime(time.gmtime(time.time()))
File "C:\Python25\lib\socket.py", line 262, in write
self.flush()
File "C:\Python25\lib\socket.py", line 249, in flush
self._sock.sendall(buffer)
error: (10054, 'Connection reset by peer')

The admin app still appears to work and I can put new entries into the
table. I just keep getting these tracebacks anytime there is a date/
time in the view. This does not appear on the Choices screen which
has no date in the tutorial, but if I add a date/time field, it starts
to happen there. Of course, the traceback indicates that it is
happening on the time.asctime() call.

Is there something that changed in Python 2.5 that causes this?

HELP :-(

Jon Rosen

Eric Liu

unread,
Apr 17, 2008, 12:00:16 PM4/17/08
to django...@googlegroups.com
Hi,
May be you can post your source code,then we can check it whether there are some wongs with it.

Jon

unread,
Apr 17, 2008, 1:12:26 PM4/17/08
to Django users
Sure!

On Apr 17, 12:00 pm, "Eric Liu" <eric.la...@gmail.com> wrote:
> Hi,
> May be you can post your source code,then we can check it whether there are
> some wongs with it.
>

I simply cut and paste from the tutorial, but here 'tis:

===============================
polls/models.py:
===============================
from django.db import models

# Create your models here.
from django.db import models

class Poll(models.Model):
question = models.CharField(maxlength=200)
pub_date = models.DateTimeField('date published')
def __str__(self):
return self.question

class Admin:
pass

class Choice(models.Model):
poll = models.ForeignKey(Poll)
choice = models.CharField(maxlength=200)
votes = models.IntegerField()
# ...
def __str__(self):
return self.choice

class Admin:
pass
===============================
polls/urls.py:
===============================
from django.conf.urls.defaults import *

urlpatterns = patterns('',
(r'^admin/', include('django.contrib.admin.urls')),
)
===============================

And that is it :-) Like I said, it was cut-and-paste from the
standard tutorial so unless I screwed something up, I don't see why I
am getting the weird error.

Thanks!

Jon

Hernan Olivera

unread,
Apr 17, 2008, 1:27:47 PM4/17/08
to django...@googlegroups.com
Maybe something about your database settings.
You don't say what db are you using in each case.

Jon

unread,
Apr 17, 2008, 1:36:12 PM4/17/08
to Django users
Both cases I am using MySQL 5.0. However, new info: this ONLY appears
in IE. When I use Firefox, this doesn't happen. I think this may be
an IE 6.0 problem. I am using IE 6.0 on this machine, but at home, i
was using IE 7.0.

Still, this seems really weird.

Also, when I switch from http://localhost:8000/admin/ to
http://127.0.0.1:8000/admin/, the second exception that was occurring
above disappears (only the first remains). And when I switch to
Firefox, no problems at all.

Any ideas?

Jon

Jon

unread,
Apr 17, 2008, 3:14:49 PM4/17/08
to Django users
Answering my own question here :-) It looks like this is related to
the proxy server settings in IE. Home machine didn't use a proxy
server - no problem on IE7 (and probably not a problem on IE6 either).
On work machine, there is a proxy server in the settings and localhost
isn't automatically exempted so this was going through the proxy
server. When I added localhost to the sites that don't use the proxy
server, it worked in IE6 (and IE7). Firefox apparently always exempts
localhost (or at least by default) so that was probably why I saw the
immediate difference between IE and FF

So, problem appears to have been solved!

Jon
Reply all
Reply to author
Forward
0 new messages