Discussion:
n00b to Django - simple Django example crashes :-(
z0ltan
2007-04-22 17:25:18 UTC
Permalink
Hi folks,
I have been bitten by the Python bug and have decided to jump
into web development using Python and what can I say, I found Django's
charms too hard to resist! But there seems to be some trouble in
paradise ... lemme explain in brief -

I setup up Django 0.95 on my system alongwith Python 2.5. Installation
went off smoothly without any errors. To test the configuration, I
started following the steps and examples given in "The Django Book".
The code is basically the following:
from django.http import HttpResponse
from mysite.views import current_daytime

def current_datettime(request):
now = datetime.datetime.now()
html = "<html><body>The current time is %s.</body></
html>" % now
return HttpResponse(html)

"mysite" being, of course, the project created using the command
"manage.py startproject mysite" from the ...\django\bin directory. I
started the built-in Django server using the command "manage.py
runserver 8001" (note:
as required, I had suitably modified the 'urls.py' file in the mysite
directory).

The server runs fine. I even get the initial server screen (before
making the above modifications). However when I access the server
through the browser as "http://127.0.0.1:8001/now" ( note: the
'urls.py file reads as:

from django.conf.urls.defaults import *
from mysite.views import current_datetime

urlpatterns = patterns('',
(r'^now/$',current_datetime),
)

)

However, the browser ( I tried on both IE and Mozilla Firefox ) throws
up the following error :
(Sorry, it's quite a bit long!!!)


<error message starts here>

AttributeError at /now/
'function' object has no attribute 'rindex'
Request Method: GET
Request URL: http://127.0.0.1:8001/now/
Exception Type: AttributeError
Exception Value: 'function' object has no attribute 'rindex'
Exception Location: C:\Python25\lib\site-packages\django-0.95.1-
py2.5.egg\django\core\urlresolvers.py in get_mod_func, line 23
Traceback (innermost last)
Switch to copy-and-paste view

* C:\Python25\lib\site-packages\django-0.95.1-py2.5.egg\django\core
\handlers\base.py in get_response
58. for middleware_method in self._request_middleware:
59. response = middleware_method(request)
60. if response:
61. return response
62.
63. resolver = urlresolvers.RegexURLResolver(r'^/',
settings.ROOT_URLCONF)
64. try:
65. callback, callback_args, callback_kwargs =
resolver.resolve(path) ...
66.
67. # Apply view middleware
68. for middleware_method in self._view_middleware:
69. response = middleware_method(request, callback,
callback_args, callback_kwargs)
70. if response:
71. return response
▶ Local vars
Variable Value
exceptions
<module 'django.core.exceptions' from 'C:\Python25\lib\site-
packages\django-0.95.1-py2.5.egg\django\core\exceptions.py'>
mail_admins
<function mail_admins at 0x0111AE30>
middleware_method
<bound method AuthenticationMiddleware.process_request of
<django.contrib.auth.middleware.AuthenticationMiddleware object at
0x01143910>>
path
'/now/'
request
<WSGIRequest GET:<MultiValueDict: {}>, POST:<MultiValueDict:
{}>, COOKIES:{}, META:{'ALLUSERSPROFILE': 'C:\\Documents and Settings\
\All Users', 'APPDATA': 'C:\\Documents and Settings\\Timmy Jose\
\Application Data', 'CLASSPATH': 'C:\\Program Files\\Java\\jre1.5.0_06\
\lib\\ext\\QTJava.zip', 'CLIENTNAME': 'Console', 'COMMONPROGRAMFILES':
'C:\\Program Files\\Common Files', 'COMPUTERNAME': 'HOZEY', 'COMSPEC':
'C:\\WINDOWS\\system32\\cmd.exe', 'CONTENT_LENGTH': '',
'CONTENT_TYPE': 'text/plain', 'DJANGO_SETTINGS_MODULE':
'mysite.settings', 'FP_NO_HOST_CHECK': 'NO', 'GATEWAY_INTERFACE': 'CGI/
1.1', 'HOMEDRIVE': 'C:', 'HOMEPATH': '\\Documents and Settings\\Timmy
Jose', 'HTTP_ACCEPT': 'text/xml,application/xml,application/xhtml
+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5',
'HTTP_ACCEPT_CHARSET': 'ISO-8859-1,utf-8;q=0.7,*;q=0.7',
'HTTP_ACCEPT_ENCODING': 'gzip,deflate', 'HTTP_ACCEPT_LANGUAGE': 'en-
us,en;q=0.5', 'HTTP_CONNECTION': 'keep-alive', 'HTTP_HOST':
'127.0.0.1:8001', 'HTTP_KEEP_ALIVE': '300', 'HTTP_USER_AGENT':
'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.3) Gecko/
20070309 Firefox/2.0.0.3', 'LOGONSERVER': '\\\\HOZEY',
'NUMBER_OF_PROCESSORS': '2', 'OS': 'Windows_NT', 'PATH': 'C:\\WINDOWS\
\system32;C:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem;C:\\Program Files\
\QuickTime\\QTSystem\\;C:\\Program Files\\Common Files\\GTK\\2.0\
\bin;c:\\Python25', 'PATHEXT':
'.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH', 'PATH_INFO': '/
now/', 'PCTYPE': 'PRESARIO', 'PGLOCALEDIR': 'C:\\Program Files\
\PostgreSQL\\8.2\\share\\locale', 'PLATFORM': 'MCD',
'PROCESSOR_ARCHITECTURE': 'x86', 'PROCESSOR_IDENTIFIER': 'x86 Family
15 Model 72 Stepping 2, AuthenticAMD', 'PROCESSOR_LEVEL': '15',
'PROCESSOR_REVISION': '4802', 'PROGRAMFILES': 'C:\\Program Files',
'PROMPT': '$P$G', 'QTJAVA': 'C:\\Program Files\\Java\\jre1.5.0_06\\lib\
\ext\\QTJava.zip', 'QUERY_STRING': '', 'REMOTE_ADDR': '127.0.0.1',
'REMOTE_HOST': 'localhost', 'REQUEST_METHOD': 'GET', 'RUN_MAIN':
'true', 'SCRIPT_NAME': '', 'SERVER_NAME': 'localhost', 'SERVER_PORT':
'8001', 'SERVER_PROTOCOL': 'HTTP/1.1', 'SERVER_SOFTWARE': 'WSGIServer/
0.1 Python/2.5', 'SESSIONNAME': 'Console', 'SONICCENTRAL': 'C:\
\Program Files\\Common Files\\Sonic Shared\\Sonic Central\\',
'SYSTEMDRIVE': 'C:', 'SYSTEMROOT': 'C:\\WINDOWS', 'TEMP': 'C:\
\DOCUME~1\\TIMMYJ~2\\LOCALS~1\\Temp', 'TMP': 'C:\\DOCUME~1\\TIMMYJ~2\
\LOCALS~1\\Temp', 'TZ': 'America/Chicago', 'USERDOMAIN': 'HOZEY',
'USERNAME': 'Timmy Jose', 'USERPROFILE': 'C:\\Documents and Settings\
\Timmy Jose', 'WINDIR': 'C:\\WINDOWS', 'wsgi.errors': <open file
'<stderr>', mode 'w' at 0x00A7F0B0>, 'wsgi.file_wrapper': <class
'django.core.servers.basehttp.FileWrapper'>, 'wsgi.input':
<socket._fileobject object at 0x00D086F8>, 'wsgi.multiprocess': False,
'wsgi.multithread': True, 'wsgi.run_once': False, 'wsgi.url_scheme':
'http', 'wsgi.version': (1, 0)}>
resolver
<django.core.urlresolvers.RegexURLResolver object at 0x0114D510>
response
None
self
<django.core.handlers.wsgi.WSGIHandler object at 0x00D312F0>
settings
<django.conf.LazySettings object at 0x00B57790>
urlresolvers
<module 'django.core.urlresolvers' from 'C:\Python25\lib\site-
packages\django-0.95.1-py2.5.egg\django\core\urlresolvers.py'>
* C:\Python25\lib\site-packages\django-0.95.1-py2.5.egg\django\core
\urlresolvers.py in resolve
140. def resolve(self, path):
141. tried = []
142. match = self.regex.search(path)
143. if match:
144. new_path = path[match.end():]
145. for pattern in self.urlconf_module.urlpatterns:
146. try:
147. sub_match = pattern.resolve(new_path) ...
148. except Resolver404, e:
149. tried.extend([(pattern.regex.pattern + ' ' + t) for t in
e.args[0]['tried']])
150. else:
151. if sub_match:
152. return sub_match[0], sub_match[1], dict(match.groupdict(),
**sub_match[2])
153. tried.append(pattern.regex.pattern)
▶ Local vars
Variable Value
match
<_sre.SRE_Match object at 0x0115C3D8>
new_path
'now/'
path
'/now/'
pattern
<django.core.urlresolvers.RegexURLPattern object at 0x0114DF30>
self
<django.core.urlresolvers.RegexURLResolver object at 0x0114D510>
tried
[]
* C:\Python25\lib\site-packages\django-0.95.1-py2.5.egg\django\core
\urlresolvers.py in resolve
105. args = match.groups()
106. # In both cases, pass any extra_kwargs as **kwargs.
107. kwargs.update(self.default_args)
108.
109. try: # Lazily load self.func.
110. return self.func, args, kwargs
111. except AttributeError:
112. self.func = self.get_callback() ...
113. return self.func, args, kwargs
114.
115. def get_callback(self):
116. mod_name, func_name = get_mod_func(self.callback)
117. try:
118. return getattr(__import__(mod_name, '', '', ['']),
func_name)
▶ Local vars
Variable Value
args
()
kwargs
{}
match
<_sre.SRE_Match object at 0x0115C560>
path
'now/'
self
<django.core.urlresolvers.RegexURLPattern object at 0x0114DF30>
* C:\Python25\lib\site-packages\django-0.95.1-py2.5.egg\django\core
\urlresolvers.py in get_callback
109. try: # Lazily load self.func.
110. return self.func, args, kwargs
111. except AttributeError:
112. self.func = self.get_callback()
113. return self.func, args, kwargs
114.
115. def get_callback(self):
116. mod_name, func_name = get_mod_func(self.callback) ...
117. try:
118. return getattr(__import__(mod_name, '', '', ['']),
func_name)
119. except ImportError, e:
120. raise ViewDoesNotExist, "Could not import %s. Error was:
%s" % (mod_name, str(e))
121. except AttributeError, e:
122. raise ViewDoesNotExist, "Tried %s in module %s. Error was:
%s" % (func_name, mod_name, str(e))
▶ Local vars
Variable Value
self
<django.core.urlresolvers.RegexURLPattern object at 0x0114DF30>
* C:\Python25\lib\site-packages\django-0.95.1-py2.5.egg\django\core
\urlresolvers.py in get_mod_func
16.
17. class NoReverseMatch(Exception):
18. pass
19.
20. def get_mod_func(callback):
21. # Converts 'django.views.news.stories.story_detail' to
22. # ['django.views.news.stories', 'story_detail']
23. dot = callback.rindex('.') ...
24. return callback[:dot], callback[dot+1:]
25.
26. def reverse_helper(regex, *args, **kwargs):
27. """
28. Does a "reverse" lookup -- returns the URL for the given
args/kwargs.
29. The args/kwargs are applied to the given compiled regular
expression.
▶ Local vars
Variable Value
callback
<function current_datetime at 0x01151BB0>

Traceback (most recent call last):
File "C:\Python25\lib\site-packages\django-0.95.1-py2.5.egg\django\core
\handlers\base.py" in get_response
65. callback, callback_args, callback_kwargs =
resolver.resolve(path)
File "C:\Python25\lib\site-packages\django-0.95.1-py2.5.egg\django\core
\urlresolvers.py" in resolve
147. sub_match = pattern.resolve(new_path)
File "C:\Python25\lib\site-packages\django-0.95.1-py2.5.egg\django\core
\urlresolvers.py" in resolve
112. self.func = self.get_callback()
File "C:\Python25\lib\site-packages\django-0.95.1-py2.5.egg\django\core
\urlresolvers.py" in get_callback
116. mod_name, func_name = get_mod_func(self.callback)
File "C:\Python25\lib\site-packages\django-0.95.1-py2.5.egg\django\core
\urlresolvers.py" in get_mod_func
23. dot = callback.rindex('.')

AttributeError at /now/
'function' object has no attribute 'rindex'
Request information
GET

No GET data
POST

No POST data
COOKIES

No cookie data
META
Variable Value
ALLUSERSPROFILE
'C:\\Documents and Settings\\All Users'
APPDATA
'C:\\Documents and Settings\\Timmy Jose\\Application Data'
CLASSPATH
'C:\\Program Files\\Java\\jre1.5.0_06\\lib\\ext\\QTJava.zip'
CLIENTNAME
'Console'
COMMONPROGRAMFILES
'C:\\Program Files\\Common Files'
COMPUTERNAME
'HOZEY'
COMSPEC
'C:\\WINDOWS\\system32\\cmd.exe'
CONTENT_LENGTH
''
CONTENT_TYPE
'text/plain'
DJANGO_SETTINGS_MODULE
'mysite.settings'
FP_NO_HOST_CHECK
'NO'
GATEWAY_INTERFACE
'CGI/1.1'
HOMEDRIVE
'C:'
HOMEPATH
'\\Documents and Settings\\Timmy Jose'
HTTP_ACCEPT
'text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/
plain;q=0.8,image/png,*/*;q=0.5'
HTTP_ACCEPT_CHARSET
'ISO-8859-1,utf-8;q=0.7,*;q=0.7'
HTTP_ACCEPT_ENCODING
'gzip,deflate'
HTTP_ACCEPT_LANGUAGE
'en-us,en;q=0.5'
HTTP_CONNECTION
'keep-alive'
HTTP_HOST
'127.0.0.1:8001'
HTTP_KEEP_ALIVE
'300'
HTTP_USER_AGENT
'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.3) Gecko/
20070309 Firefox/2.0.0.3'
LOGONSERVER
'\\\\HOZEY'
NUMBER_OF_PROCESSORS
'2'
OS
'Windows_NT'
PATH
'C:\\WINDOWS\\system32;C:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem;C:\
\Program Files\\QuickTime\\QTSystem\\;C:\\Program Files\\Common Files\
\GTK\\2.0\\bin;c:\\Python25'
PATHEXT
'.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH'
PATH_INFO
'/now/'
PCTYPE
'PRESARIO'
PGLOCALEDIR
'C:\\Program Files\\PostgreSQL\\8.2\\share\\locale'
PLATFORM
'MCD'
PROCESSOR_ARCHITECTURE
'x86'
PROCESSOR_IDENTIFIER
'x86 Family 15 Model 72 Stepping 2, AuthenticAMD'
PROCESSOR_LEVEL
'15'
PROCESSOR_REVISION
'4802'
PROGRAMFILES
'C:\\Program Files'
PROMPT
'$P$G'
QTJAVA
'C:\\Program Files\\Java\\jre1.5.0_06\\lib\\ext\\QTJava.zip'
QUERY_STRING
''
REMOTE_ADDR
'127.0.0.1'
REMOTE_HOST
'localhost'
REQUEST_METHOD
'GET'
RUN_MAIN
'true'
SCRIPT_NAME
''
SERVER_NAME
'localhost'
SERVER_PORT
'8001'
SERVER_PROTOCOL
'HTTP/1.1'
SERVER_SOFTWARE
'WSGIServer/0.1 Python/2.5'
SESSIONNAME
'Console'
SONICCENTRAL
'C:\\Program Files\\Common Files\\Sonic Shared\\Sonic Central\\'
SYSTEMDRIVE
'C:'
SYSTEMROOT
'C:\\WINDOWS'
TEMP
'C:\\DOCUME~1\\TIMMYJ~2\\LOCALS~1\\Temp'
TMP
'C:\\DOCUME~1\\TIMMYJ~2\\LOCALS~1\\Temp'
TZ
'America/Chicago'
USERDOMAIN
'HOZEY'
USERNAME
'Timmy Jose'
USERPROFILE
'C:\\Documents and Settings\\Timmy Jose'
WINDIR
'C:\\WINDOWS'
wsgi.errors
<open file '<stderr>', mode 'w' at 0x00A7F0B0>
wsgi.file_wrapper
<class 'django.core.servers.basehttp.FileWrapper'>
wsgi.input
<socket._fileobject object at 0x00D086F8>
wsgi.multiprocess
False
wsgi.multithread
True
wsgi.run_once
False
wsgi.url_scheme
'http'
wsgi.version
(1, 0)
Settings
Using settings module mysite.settings
Setting Value
ABSOLUTE_URL_OVERRIDES
{}
ADMINS
()
ADMIN_FOR
()
ADMIN_MEDIA_PREFIX
'/media/'
ALLOWED_INCLUDE_ROOTS
()
APPEND_SLASH
True
AUTHENTICATION_BACKENDS
('django.contrib.auth.backends.ModelBackend',)
BANNED_IPS
()
CACHE_BACKEND
'simple://'
CACHE_MIDDLEWARE_KEY_PREFIX
''
COMMENTS_ALLOW_PROFANITIES
False
COMMENTS_BANNED_USERS_GROUP
None
COMMENTS_FIRST_FEW
0
COMMENTS_MODERATORS_GROUP
None
COMMENTS_SKETCHY_USERS_GROUP
None
DATABASE_ENGINE
'dummy'
DATABASE_HOST
''
DATABASE_NAME
''
DATABASE_PASSWORD
'********************'
DATABASE_PORT
''
DATABASE_USER
''
DATETIME_FORMAT
'N j, Y, P'
DATE_FORMAT
'N j, Y'
DEBUG
True
DEFAULT_CHARSET
'utf-8'
DEFAULT_CONTENT_TYPE
'text/html'
DEFAULT_FROM_EMAIL
'***@localhost'
DISALLOWED_USER_AGENTS
()
EMAIL_HOST
'localhost'
EMAIL_HOST_PASSWORD
'********************'
EMAIL_HOST_USER
''
EMAIL_PORT
25
EMAIL_SUBJECT_PREFIX
'[Django] '
ENABLE_PSYCO
False
IGNORABLE_404_ENDS
('mail.pl', 'mailform.pl', 'mail.cgi', 'mailform.cgi', 'favicon.ico',
'.php')
IGNORABLE_404_STARTS
('/cgi-bin/', '/_vti_bin', '/_vti_inf')
INSTALLED_APPS
['django.contrib.auth', 'django.contrib.contenttypes',
'django.contrib.sessions', 'django.contrib.sites']
INTERNAL_IPS
()
JING_PATH
'/usr/bin/jing'
LANGUAGES
(('ar', 'Arabic'), ('bn', 'Bengali'), ('cs', 'Czech'), ('cy',
'Welsh'), ('da', 'Danish'), ('de', 'German'), ('el', 'Greek'), ('en',
'English'), ('es', 'Spanish'), ('es_AR', 'Argentinean Spanish'),
('fr', 'French'), ('gl', 'Galician'), ('hu', 'Hungarian'), ('he',
'Hebrew'), ('is', 'Icelandic'), ('it', 'Italian'), ('ja', 'Japanese'),
('nl', 'Dutch'), ('no', 'Norwegian'), ('pt-br', 'Brazilian'), ('ro',
'Romanian'), ('ru', 'Russian'), ('sk', 'Slovak'), ('sl', 'Slovenian'),
('sr', 'Serbian'), ('sv', 'Swedish'), ('ta', 'Tamil'), ('uk',
'Ukrainian'), ('zh-cn', 'Simplified Chinese'), ('zh-tw', 'Traditional
Chinese'))
LANGUAGES_BIDI
('he', 'ar')
LANGUAGE_CODE
'en-us'
MANAGERS
()
MEDIA_ROOT
''
MEDIA_URL
''
MIDDLEWARE_CLASSES
('django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.middleware.doc.XViewMiddleware')
MONTH_DAY_FORMAT
'F j'
PREPEND_WWW
False
ROOT_URLCONF
'mysite.urls'
SECRET_KEY
'********************'
SEND_BROKEN_LINK_EMAILS
False
SERVER_EMAIL
'***@localhost'
SESSION_COOKIE_AGE
1209600
SESSION_COOKIE_DOMAIN
None
SESSION_COOKIE_NAME
'sessionid'
SESSION_EXPIRE_AT_BROWSER_CLOSE
False
SESSION_SAVE_EVERY_REQUEST
False
SETTINGS_MODULE
'mysite.settings'
SITE_ID
1
TEMPLATE_CONTEXT_PROCESSORS
('django.core.context_processors.auth',
'django.core.context_processors.debug',
'django.core.context_processors.i18n')
TEMPLATE_DEBUG
True
TEMPLATE_DIRS
()
TEMPLATE_LOADERS
('django.template.loaders.filesystem.load_template_source',
'django.template.loaders.app_directories.load_template_source')
TEMPLATE_STRING_IF_INVALID
''
TIME_FORMAT
'P'
TIME_ZONE
'America/Chicago'
TRANSACTIONS_MANAGED
False
USE_ETAGS
False
USE_I18N
True
YEAR_MONTH_FORMAT
'F Y'

<error message ends here>
You're seeing this error because you have DEBUG = True in your Django
settings file. Change that to False, and Django will display a
standard 500 page.


I figured that there was some problem with the get_mod_func method in
the urlresolvers.py file inside django\core directory and that the
'rindex' method was being applied to a non-string. Tried some mods
using "str" but didn't solve the problem.

Could someone please explain what's going on and how to fix the
problem?

Thanks,

Timmy Jose.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-***@googlegroups.com
To unsubscribe from this group, send email to django-users-***@googlegroups.com
For more options, visit this group at http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---
robin_percy
2007-04-22 17:53:33 UTC
Permalink
This is most likely because you're using 0.95 instead of 0.96. The
error is documented here:
http://code.djangoproject.com/wiki/IrcFAQ#WeirdError1
Post by z0ltan
Hi folks,
I have been bitten by the Python bug and have decided to jump
into web development using Python and what can I say, I found Django's
charms too hard to resist! But there seems to be some trouble in
paradise ... lemme explain in brief -
I setup up Django 0.95 on my system alongwith Python 2.5. Installation
went off smoothly without any errors. To test the configuration, I
started following the steps and examples given in "The Django Book".
from django.http import HttpResponse
from mysite.views import current_daytime
now = datetime.datetime.now()
html = "<html><body>The current time is %s.</body></
html>" % now
return HttpResponse(html)
"mysite" being, of course, the project created using the command
"manage.py startproject mysite" from the ...\django\bin directory. I
started the built-in Django server using the command "manage.py
as required, I had suitably modified the 'urls.py' file in the mysite
directory).
The server runs fine. I even get the initial server screen (before
making the above modifications). However when I access the server
through the browser as "http://127.0.0.1:8001/now" ( note: the
from django.conf.urls.defaults import *
from mysite.views import current_datetime
urlpatterns = patterns('',
(r'^now/$',current_datetime),
)
)
However, the browser ( I tried on both IE and Mozilla Firefox ) throws
(Sorry, it's quite a bit long!!!)
<error message starts here>
AttributeError at /now/
'function' object has no attribute 'rindex'
Request Method: GET
Request URL: http://127.0.0.1:8001/now/
Exception Type: AttributeError
Exception Value: 'function' object has no attribute 'rindex'
Exception Location: C:\Python25\lib\site-packages\django-0.95.1-
py2.5.egg\django\core\urlresolvers.py in get_mod_func, line 23
Traceback (innermost last)
Switch to copy-and-paste view
* C:\Python25\lib\site-packages\django-0.95.1-py2.5.egg\django\core
\handlers\base.py in get_response
59. response = middleware_method(request)
61. return response
62.
63. resolver = urlresolvers.RegexURLResolver(r'^/',
settings.ROOT_URLCONF)
65. callback, callback_args, callback_kwargs =
resolver.resolve(path) ...
66.
67. # Apply view middleware
69. response = middleware_method(request, callback,
callback_args, callback_kwargs)
71. return response
▶ Local vars
Variable Value
exceptions
<module 'django.core.exceptions' from 'C:\Python25\lib\site-
packages\django-0.95.1-py2.5.egg\django\core\exceptions.py'>
mail_admins
<function mail_admins at 0x0111AE30>
middleware_method
<bound method AuthenticationMiddleware.process_request of
<django.contrib.auth.middleware.AuthenticationMiddleware object at
0x01143910>>
path
'/now/'
request
{}>, COOKIES:{}, META:{'ALLUSERSPROFILE': 'C:\\Documents and Settings\
\All Users', 'APPDATA': 'C:\\Documents and Settings\\Timmy Jose\
\Application Data', 'CLASSPATH': 'C:\\Program Files\\Java\\jre1.5.0_06\
'C:\\WINDOWS\\system32\\cmd.exe', 'CONTENT_LENGTH': '',
'mysite.settings', 'FP_NO_HOST_CHECK': 'NO', 'GATEWAY_INTERFACE': 'CGI/
1.1', 'HOMEDRIVE': 'C:', 'HOMEPATH': '\\Documents and Settings\\Timmy
Jose', 'HTTP_ACCEPT': 'text/xml,application/xml,application/xhtml
+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5',
'HTTP_ACCEPT_CHARSET': 'ISO-8859-1,utf-8;q=0.7,*;q=0.7',
'HTTP_ACCEPT_ENCODING': 'gzip,deflate', 'HTTP_ACCEPT_LANGUAGE': 'en-
'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.3) Gecko/
20070309 Firefox/2.0.0.3', 'LOGONSERVER': '\\\\HOZEY',
'NUMBER_OF_PROCESSORS': '2', 'OS': 'Windows_NT', 'PATH': 'C:\\WINDOWS\
\system32;C:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem;C:\\Program Files\
\QuickTime\\QTSystem\\;C:\\Program Files\\Common Files\\GTK\\2.0\
'.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH', 'PATH_INFO': '/
now/', 'PCTYPE': 'PRESARIO', 'PGLOCALEDIR': 'C:\\Program Files\
\PostgreSQL\\8.2\\share\\locale', 'PLATFORM': 'MCD',
'PROCESSOR_ARCHITECTURE': 'x86', 'PROCESSOR_IDENTIFIER': 'x86 Family
15 Model 72 Stepping 2, AuthenticAMD', 'PROCESSOR_LEVEL': '15',
'PROCESSOR_REVISION': '4802', 'PROGRAMFILES': 'C:\\Program Files',
'PROMPT': '$P$G', 'QTJAVA': 'C:\\Program Files\\Java\\jre1.5.0_06\\lib\
\ext\\QTJava.zip', 'QUERY_STRING': '', 'REMOTE_ADDR': '127.0.0.1',
'8001', 'SERVER_PROTOCOL': 'HTTP/1.1', 'SERVER_SOFTWARE': 'WSGIServer/
0.1 Python/2.5', 'SESSIONNAME': 'Console', 'SONICCENTRAL': 'C:\
\Program Files\\Common Files\\Sonic Shared\\Sonic Central\\',
'SYSTEMDRIVE': 'C:', 'SYSTEMROOT': 'C:\\WINDOWS', 'TEMP': 'C:\
\DOCUME~1\\TIMMYJ~2\\LOCALS~1\\Temp', 'TMP': 'C:\\DOCUME~1\\TIMMYJ~2\
\LOCALS~1\\Temp', 'TZ': 'America/Chicago', 'USERDOMAIN': 'HOZEY',
'USERNAME': 'Timmy Jose', 'USERPROFILE': 'C:\\Documents and Settings\
\Timmy Jose', 'WINDIR': 'C:\\WINDOWS', 'wsgi.errors': <open file
'<stderr>', mode 'w' at 0x00A7F0B0>, 'wsgi.file_wrapper': <class
<socket._fileobject object at 0x00D086F8>, 'wsgi.multiprocess': False,
'http', 'wsgi.version': (1, 0)}>
resolver
<django.core.urlresolvers.RegexURLResolver object at 0x0114D510>
response
None
self
<django.core.handlers.wsgi.WSGIHandler object at 0x00D312F0>
settings
<django.conf.LazySettings object at 0x00B57790>
urlresolvers
<module 'django.core.urlresolvers' from 'C:\Python25\lib\site-
packages\django-0.95.1-py2.5.egg\django\core\urlresolvers.py'>
* C:\Python25\lib\site-packages\django-0.95.1-py2.5.egg\django\core
\urlresolvers.py in resolve
141. tried = []
142. match = self.regex.search(path)
144. new_path = path[match.end():]
147. sub_match = pattern.resolve(new_path) ...
149. tried.extend([(pattern.regex.pattern + ' ' + t) for t in
e.args[0]['tried']])
152. return sub_match[0], sub_match[1], dict(match.groupdict(),
**sub_match[2])
153. tried.append(pattern.regex.pattern)
▶ Local vars
Variable Value
match
<_sre.SRE_Match object at 0x0115C3D8>
new_path
'now/'
path
'/now/'
pattern
<django.core.urlresolvers.RegexURLPattern object at 0x0114DF30>
self
<django.core.urlresolvers.RegexURLResolver object at 0x0114D510>
tried
[]
* C:\Python25\lib\site-packages\django-0.95.1-py2.5.egg\django\core
\urlresolvers.py in resolve
105. args = match.groups()
106. # In both cases, pass any extra_kwargs as **kwargs.
107. kwargs.update(self.default_args)
108.
109. try: # Lazily load self.func.
110. return self.func, args, kwargs
112. self.func = self.get_callback() ...
113. return self.func, args, kwargs
114.
116. mod_name, func_name = get_mod_func(self.callback)
118. return getattr(__import__(mod_name, '', '', ['']),
func_name)
▶ Local vars
Variable Value
args
()
kwargs
{}
match
<_sre.SRE_Match object at 0x0115C560>
path
'now/'
self
<django.core.urlresolvers.RegexURLPattern object at 0x0114DF30>
* C:\Python25\lib\site-packages\django-0.95.1-py2.5.egg\django\core
\urlresolvers.py in get_callback
109. try: # Lazily load self.func.
110. return self.func, args, kwargs
112. self.func = self.get_callback()
113. return self.func, args, kwargs
114.
116. mod_name, func_name = get_mod_func(self.callback) ...
118. return getattr(__import__(mod_name, '', '', ['']),
func_name)
%s" % (mod_name, str(e))
%s" % (func_name, mod_name, str(e))
▶ Local vars
Variable Value
self
<django.core.urlresolvers.RegexURLPattern object at 0x0114DF30>
* C:\Python25\lib\site-packages\django-0.95.1-py2.5.egg\django\core
\urlresolvers.py in get_mod_func
16.
18. pass
19.
21. # Converts 'django.views.news.stories.story_detail' to
22. # ['django.views.news.stories', 'story_detail']
23. dot = callback.rindex('.') ...
24. return callback[:dot], callback[dot+1:]
25.
27. """
28. Does a "reverse" lookup -- returns the URL for the given
args/kwargs.
29. The args/kwargs are applied to the given compiled regular
expression.
▶ Local vars
Variable Value
callback
<function current_datetime at 0x01151BB0>
File "C:\Python25\lib\site-packages\django-0.95.1-py2.5.egg\django\core
\handlers\base.py" in get_response
65. callback, callback_args, callback_kwargs =
resolver.resolve(path)
File "C:\Python25\lib\site-packages\django-0.95.1-py2.5.egg\django\core
\urlresolvers.py" in resolve
147. sub_match = pattern.resolve(new_path)
File "C:\Python25\lib\site-packages\django-0.95.1-py2.5.egg\django\core
\urlresolvers.py" in resolve
112. self.func = self.get_callback()
File "C:\Python25\lib\site-packages\django-0.95.1-py2.5.egg\django\core
\urlresolvers.py" in get_callback
116. mod_name, func_name = get_mod_func(self.callback)
File "C:\Python25\lib\site-packages\django-0.95.1-py2.5.egg\django\core
\urlresolvers.py" in get_mod_func
23. dot = callback.rindex('.')
AttributeError at /now/
'function' object has no attribute 'rindex'
Request information
GET
No GET data
POST
No POST data
COOKIES
No cookie data
META
Variable Value
ALLUSERSPROFILE
'C:\\Documents and Settings\\All Users'
APPDATA
'C:\\Documents and Settings\\Timmy Jose\\Application Data'
CLASSPATH
'C:\\Program Files\\Java\\jre1.5.0_06\\lib\\ext\\QTJava.zip'
CLIENTNAME
'Console'
COMMONPROGRAMFILES
'C:\\Program Files\\Common Files'
COMPUTERNAME
'HOZEY'
COMSPEC
'C:\\WINDOWS\\system32\\cmd.exe'
CONTENT_LENGTH
''
CONTENT_TYPE
'text/plain'
DJANGO_SETTINGS_MODULE
'mysite.settings'
FP_NO_HOST_CHECK
'NO'
GATEWAY_INTERFACE
'CGI/1.1'
HOMEDRIVE
'C:'
HOMEPATH
'\\Documents and Settings\\Timmy Jose'
HTTP_ACCEPT
'text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/
plain;q=0.8,image/png,*/*;q=0.5'
HTTP_ACCEPT_CHARSET
'ISO-8859-1,utf-8;q=0.7,*;q=0.7'
HTTP_ACCEPT_ENCODING
'gzip,deflate'
HTTP_ACCEPT_LANGUAGE
'en-us,en;q=0.5'
HTTP_CONNECTION
'keep-alive'
HTTP_HOST
'127.0.0.1:8001'
HTTP_KEEP_ALIVE
'300'
HTTP_USER_AGENT
'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.3) Gecko/
20070309 Firefox/2.0.0.3'
LOGONSERVER
'\\\\HOZEY'
NUMBER_OF_PROCESSORS
'2'
OS
'Windows_NT'
PATH
'C:\\WINDOWS\\system32;C:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem;C:\
\Program Files\\QuickTime\\QTSystem\\;C:\\Program Files\\Common Files\
\GTK\\2.0\\bin;c:\\Python25'
PATHEXT
'.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH'
PATH_INFO
'/now/'
PCTYPE
'PRESARIO'
PGLOCALEDIR
'C:\\Program Files\\PostgreSQL\\8.2\\share\\locale'
PLATFORM
'MCD'
PROCESSOR_ARCHITECTURE
'x86'
PROCESSOR_IDENTIFIER
'x86 Family 15 Model 72 Stepping 2, AuthenticAMD'
PROCESSOR_LEVEL
'15'
PROCESSOR_REVISION
'4802'
PROGRAMFILES
'C:\\Program Files'
PROMPT
'$P$G'
QTJAVA
'C:\\Program Files\\Java\\jre1.5.0_06\\lib\\ext\\QTJava.zip'
QUERY_STRING
''
REMOTE_ADDR
'127.0.0.1'
REMOTE_HOST
'localhost'
REQUEST_METHOD
'GET'
RUN_MAIN
'true'
SCRIPT_NAME
''
SERVER_NAME
'localhost'
SERVER_PORT
'8001'
SERVER_PROTOCOL
'HTTP/1.1'
SERVER_SOFTWARE
'WSGIServer/0.1 Python/2.5'
SESSIONNAME
'Console'
SONICCENTRAL
'C:\\Program Files\\Common Files\\Sonic Shared\\Sonic Central\\'
SYSTEMDRIVE
'C:'
SYSTEMROOT
'C:\\WINDOWS'
TEMP
'C:\\DOCUME~1\\TIMMYJ~2\\LOCALS~1\\Temp'
TMP
'C:\\DOCUME~1\\TIMMYJ~2\\LOCALS~1\\Temp'
TZ
'America/Chicago'
USERDOMAIN
'HOZEY'
USERNAME
'Timmy Jose'
USERPROFILE
'C:\\Documents and Settings\\Timmy Jose'
WINDIR
'C:\\WINDOWS'
wsgi.errors
<open file '<stderr>', mode 'w' at 0x00A7F0B0>
wsgi.file_wrapper
<class 'django.core.servers.basehttp.FileWrapper'>
wsgi.input
<socket._fileobject object at 0x00D086F8>
wsgi.multiprocess
False
wsgi.multithread
True
wsgi.run_once
False
wsgi.url_scheme
'http'
wsgi.version
(1, 0)
Settings
Using settings module mysite.settings
Setting Value
ABSOLUTE_URL_OVERRIDES
{}
ADMINS
()
ADMIN_FOR
()
ADMIN_MEDIA_PREFIX
'/media/'
ALLOWED_INCLUDE_ROOTS
()
APPEND_SLASH
True
AUTHENTICATION_BACKENDS
('django.contrib.auth.backends.ModelBackend',)
BANNED_IPS
()
CACHE_BACKEND
'simple://'
CACHE_MIDDLEWARE_KEY_PREFIX
''
COMMENTS_ALLOW_PROFANITIES
False
COMMENTS_BANNED_USERS_GROUP
None
COMMENTS_FIRST_FEW
0
COMMENTS_MODERATORS_GROUP
None
COMMENTS_SKETCHY_USERS_GROUP
None
DATABASE_ENGINE
'dummy'
DATABASE_HOST
''
DATABASE_NAME
''
DATABASE_PASSWORD
'********************'
DATABASE_PORT
''
DATABASE_USER
''
DATETIME_FORMAT
'N j, Y, P'
DATE_FORMAT
'N j, Y'
DEBUG
True
DEFAULT_CHARSET
'utf-8'
DEFAULT_CONTENT_TYPE
'text/html'
DEFAULT_FROM_EMAIL
DISALLOWED_USER_AGENTS
()
EMAIL_HOST
'localhost'
EMAIL_HOST_PASSWORD
'********************'
EMAIL_HOST_USER
''
EMAIL_PORT
25
EMAIL_SUBJECT_PREFIX
'[Django] '
ENABLE_PSYCO
False
IGNORABLE_404_ENDS
('mail.pl', 'mailform.pl', 'mail.cgi', 'mailform.cgi', 'favicon.ico',
'.php')
IGNORABLE_404_STARTS
('/cgi-bin/', '/_vti_bin', '/_vti_inf')
INSTALLED_APPS
['django.contrib.auth', 'django.contrib.contenttypes',
'django.contrib.sessions', 'django.contrib.sites']
INTERNAL_IPS
()
JING_PATH
'/usr/bin/jing'
LANGUAGES
(('ar', 'Arabic'), ('bn', 'Bengali'), ('cs', 'Czech'), ('cy',
'Welsh'), ('da', 'Danish'), ('de', 'German'), ('el', 'Greek'), ('en',
'English'), ('es', 'Spanish'), ('es_AR', 'Argentinean Spanish'),
('fr', 'French'), ('gl', 'Galician'), ('hu', 'Hungarian'), ('he',
'Hebrew'), ('is', 'Icelandic'), ('it', 'Italian'), ('ja', 'Japanese'),
('nl', 'Dutch'), ('no', 'Norwegian'), ('pt-br', 'Brazilian'), ('ro',
'Romanian'), ('ru', 'Russian'), ('sk', 'Slovak'), ('sl', 'Slovenian'),
('sr', 'Serbian'), ('sv', 'Swedish'), ('ta', 'Tamil'), ('uk',
'Ukrainian'), ('zh-cn', 'Simplified Chinese'), ('zh-tw', 'Traditional
Chinese'))
LANGUAGES_BIDI
('he', 'ar')
LANGUAGE_CODE
'en-us'
MANAGERS
()
MEDIA_ROOT
''
MEDIA_URL
''
MIDDLEWARE_CLASSES
('django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.middleware.doc.XViewMiddleware')
MONTH_DAY_FORMAT
'F j'
PREPEND_WWW
False
ROOT_URLCONF
'mysite.urls'
SECRET_KEY
'********************'
SEND_BROKEN_LINK_EMAILS
False
SERVER_EMAIL
SESSION_COOKIE_AGE
1209600
SESSION_COOKIE_DOMAIN
None
SESSION_COOKIE_NAME
'sessionid'
SESSION_EXPIRE_AT_BROWSER_CLOSE
False
SESSION_SAVE_EVERY_REQUEST
False
SETTINGS_MODULE
'mysite.settings'
SITE_ID
1
TEMPLATE_CONTEXT_PROCESSORS
('django.core.context_processors.auth',
'django.core.context_processors.debug',
'django.core.context_processors.i18n')
TEMPLATE_DEBUG
True
TEMPLATE_DIRS
()
TEMPLATE_LOADERS
('django.template.loaders.filesystem.load_template_source',
'django.template.loaders.app_directories.load_template_source')
TEMPLATE_STRING_IF_INVALID
''
TIME_FORMAT
'P'
TIME_ZONE
'America/Chicago'
TRANSACTIONS_MANAGED
False
USE_ETAGS
False
USE_I18N
True
YEAR_MONTH_FORMAT
'F Y'
<error message ends here>
You're seeing this error because you have DEBUG = True in your Django
settings file. Change that to False, and Django will display a
standard 500 page.
I figured that there was some problem with the get_mod_func method in
the urlresolvers.py file inside django\core directory and that the
'rindex' method was being applied to a non-string. Tried some mods
using "str" but didn't solve the problem.
Could someone please explain what's going on and how to fix the
problem?
Thanks,
Timmy Jose.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-***@googlegroups.com
To unsubscribe from this group, send email to django-users-***@googlegroups.com
For more options, visit this group at http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---
z0ltan
2007-04-23 04:19:22 UTC
Permalink
robin_percy,

Many thanks for pointing out the defect! It was just like you had
said, the example worked fine with Django 0.96! However, an
interesting fact I noticed was that
Django 0.96's installer wouldn't install on my Windows box. It was
throwing up and error "couldn't find directory \django" and stuff like
that! So I decided to hack around a bit and found that the problem was
in the "setup.py" file where it tries to extract the "root directory"
and then navigate to the child directories from thence.
Apparently it was using "/" as the root directory even though mine was
a Windows box. So when I manually changed the root directory to "c:
\<whatever path!>", it worked fine. Am planning to raise a new ticket
on this one... thanks again for the help!

Regards,

Timmy Jose.
This is most likely because you're using 0.95 instead of 0.96.  The
error is documented here:http://code.djangoproject.com/wiki/IrcFAQ#WeirdError1
Post by z0ltan
Hi folks,
     I have been bitten by the Python bug and have decided to jump
into web development using Python and what can I say, I found Django's
charms too hard to resist! But there seems to be some trouble in
paradise ... lemme explain in brief -
I setup up Django 0.95 on my system alongwith Python 2.5. Installation
went off smoothly without any errors. To test the configuration, I
started following the steps and examples given in "The Django Book".
       from django.http import HttpResponse
       from mysite.views import current_daytime
              now = datetime.datetime.now()
              html = "<html><body>The current time is %s.</body></
html>" % now
              return HttpResponse(html)
"mysite" being, of course, the project created using the command
"manage.py startproject mysite" from the ...\django\bin directory. I
started the built-in Django server using the command "manage.py
as required, I had suitably modified the 'urls.py' file in the mysite
directory).
The server runs fine. I even get the initial server screen (before
making the above modifications). However when I access the server
through the browser as "http://127.0.0.1:8001/now" ( note: the
from django.conf.urls.defaults import *
from mysite.views import current_datetime
urlpatterns = patterns('',
                (r'^now/$',current_datetime),
                )
)
However, the browser ( I tried on both IE and Mozilla Firefox ) throws
(Sorry, it's quite a bit long!!!)
<error message starts here>
AttributeError at /now/
'function' object has no attribute 'rindex'
Request Method:         GET
Request URL:    http://127.0.0.1:8001/now/
Exception Type:         AttributeError
Exception Value:        'function' object has no attribute 'rindex'
Exception Location:     C:\Python25\lib\site-packages\django-0.95.1-
py2.5.egg\django\core\urlresolvers.py in get_mod_func, line 23
Traceback (innermost last)
Switch to copy-and-paste view
    * C:\Python25\lib\site-packages\django-0.95.1-py2.5.egg\django\core
\handlers\base.py in get_response
        59. response = middleware_method(request)
        61. return response
        62.
        63. resolver = urlresolvers.RegexURLResolver(r'^/',
settings.ROOT_URLCONF)
        65. callback, callback_args, callback_kwargs =
resolver.resolve(path) ...
        66.
        67. # Apply view middleware
        69. response = middleware_method(request, callback,
callback_args, callback_kwargs)
        71. return response
      ▶ Local vars
      Variable  Value
      exceptions
      <module 'django.core.exceptions' from 'C:\Python25\lib\site-
packages\django-0.95.1-py2.5.egg\django\core\exceptions.py'>
      mail_admins
      <function mail_admins at 0x0111AE30>
      middleware_method
      <bound method AuthenticationMiddleware.process_request of
<django.contrib.auth.middleware.AuthenticationMiddleware object at
0x01143910>>
      path
      '/now/'
      request
{}>, COOKIES:{}, META:{'ALLUSERSPROFILE': 'C:\\Documents and Settings\
\All Users', 'APPDATA': 'C:\\Documents and Settings\\Timmy Jose\
\Application Data', 'CLASSPATH': 'C:\\Program Files\\Java\\jre1.5.0_06\
'C:\\WINDOWS\\system32\\cmd.exe', 'CONTENT_LENGTH': '',
'mysite.settings', 'FP_NO_HOST_CHECK': 'NO', 'GATEWAY_INTERFACE': 'CGI/
1.1', 'HOMEDRIVE': 'C:', 'HOMEPATH': '\\Documents and Settings\\Timmy
Jose', 'HTTP_ACCEPT': 'text/xml,application/xml,application/xhtml
+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5',
'HTTP_ACCEPT_CHARSET': 'ISO-8859-1,utf-8;q=0.7,*;q=0.7',
'HTTP_ACCEPT_ENCODING': 'gzip,deflate', 'HTTP_ACCEPT_LANGUAGE': 'en-
'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.3) Gecko/
20070309 Firefox/2.0.0.3', 'LOGONSERVER': '\\\\HOZEY',
'NUMBER_OF_PROCESSORS': '2', 'OS': 'Windows_NT', 'PATH': 'C:\\WINDOWS\
\system32;C:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem;C:\\Program Files\
\QuickTime\\QTSystem\\;C:\\Program Files\\Common Files\\GTK\\2.0\
'.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH', 'PATH_INFO': '/
now/', 'PCTYPE': 'PRESARIO', 'PGLOCALEDIR': 'C:\\Program Files\
\PostgreSQL\\8.2\\share\\locale', 'PLATFORM': 'MCD',
'PROCESSOR_ARCHITECTURE': 'x86', 'PROCESSOR_IDENTIFIER': 'x86 Family
15 Model 72 Stepping 2, AuthenticAMD', 'PROCESSOR_LEVEL': '15',
'PROCESSOR_REVISION': '4802', 'PROGRAMFILES': 'C:\\Program Files',
'PROMPT': '$P$G', 'QTJAVA': 'C:\\Program Files\\Java\\jre1.5.0_06\\lib\
\ext\\QTJava.zip', 'QUERY_STRING': '', 'REMOTE_ADDR': '127.0.0.1',
'8001', 'SERVER_PROTOCOL': 'HTTP/1.1', 'SERVER_SOFTWARE': 'WSGIServer/
0.1 Python/2.5', 'SESSIONNAME': 'Console', 'SONICCENTRAL': 'C:\
\Program Files\\Common Files\\Sonic Shared\\Sonic Central\\',
'SYSTEMDRIVE': 'C:', 'SYSTEMROOT': 'C:\\WINDOWS', 'TEMP': 'C:\
\DOCUME~1\\TIMMYJ~2\\LOCALS~1\\Temp', 'TMP': 'C:\\DOCUME~1\\TIMMYJ~2\
\LOCALS~1\\Temp', 'TZ': 'America/Chicago', 'USERDOMAIN': 'HOZEY',
'USERNAME': 'Timmy Jose', 'USERPROFILE': 'C:\\Documents and Settings\
\Timmy Jose', 'WINDIR': 'C:\\WINDOWS', 'wsgi.errors': <open file
'<stderr>', mode 'w' at 0x00A7F0B0>, 'wsgi.file_wrapper': <class
<socket._fileobject object at 0x00D086F8>, 'wsgi.multiprocess': False,
'http', 'wsgi.version': (1, 0)}>
      resolver
      <django.core.urlresolvers.RegexURLResolver object at 0x0114D510>
      response
      None
      self
      <django.core.handlers.wsgi.WSGIHandler object at 0x00D312F0>
      settings
      <django.conf.LazySettings object at 0x00B57790>
      urlresolvers
      <module 'django.core.urlresolvers' from 'C:\Python25\lib\site-
packages\django-0.95.1-py2.5.egg\django\core\urlresolvers.py'>
    * C:\Python25\lib\site-packages\django-0.95.1-py2.5.egg\django\core
\urlresolvers.py in resolve
       141. tried = []
       142. match = self.regex.search(path)
       144. new_path = path[match.end():]
       147. sub_match = pattern.resolve(new_path) ...
       149. tried.extend([(pattern.regex.pattern + ' ' + t) for t in
e.args[0]['tried']])
       152. return sub_match[0], sub_match[1], dict(match.groupdict(),
**sub_match[2])
       153. tried.append(pattern.regex.pattern)
      ▶ Local vars
      Variable  Value
      match
      <_sre.SRE_Match object at 0x0115C3D8>
      new_path
      'now/'
      path
      '/now/'
      pattern
      <django.core.urlresolvers.RegexURLPattern object at 0x0114DF30>
      self
      <django.core.urlresolvers.RegexURLResolver object at 0x0114D510>
      tried
      []
    * C:\Python25\lib\site-packages\django-0.95.1-py2.5.egg\django\core
\urlresolvers.py in resolve
       105. args = match.groups()
       106. # In both cases, pass any extra_kwargs as **kwargs.
       107. kwargs.update(self.default_args)
       108.
       109. try: # Lazily load self.func.
       110. return self.func, args, kwargs
       112. self.func = self.get_callback() ...
       113. return self.func, args, kwargs
       114.
       116. mod_name, func_name = get_mod_func(self.callback)
       118. return getattr(__import__(mod_name, '', '', ['']),
func_name)
      ▶ Local vars
      Variable  Value
      args
      ()
      kwargs
      {}
      match
      <_sre.SRE_Match object at 0x0115C560>
      path
      'now/'
      self
      <django.core.urlresolvers.RegexURLPattern object at 0x0114DF30>
    * C:\Python25\lib\site-packages\django-0.95.1-py2.5.egg\django\core
\urlresolvers.py in get_callback
       109. try: # Lazily load self.func.
       110. return self.func, args, kwargs
       112. self.func = self.get_callback()
       113. return self.func, args, kwargs
       114.
       116. mod_name, func_name = get_mod_func(self.callback) ...
       118. return getattr(__import__(mod_name, '', '', ['']),
func_name)
%s" % (mod_name, str(e))
%s" % (func_name, mod_name, str(e))
      ▶ Local vars
...
read more »
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-***@googlegroups.com
To unsubscribe from this group, send email to django-users-***@googlegroups.com
For more options, visit this group at http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---
Malcolm Tredinnick
2007-04-23 04:57:30 UTC
Permalink
On Mon, 2007-04-23 at 04:19 +0000, z0ltan wrote:
[...]
Post by z0ltan
and then navigate to the child directories from thence.
Apparently it was using "/" as the root directory even though mine was
\<whatever path!>", it worked fine. Am planning to raise a new ticket
on this one... thanks again for the help!
Please always try to search existing tickets, including closed ones,
before doing this (opening a new ticket). In this case, you will
hopefulyl discover that the problem has been reported and was fixed
shortly after the 0.96 release.

Regards,
Malcolm



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-***@googlegroups.com
To unsubscribe from this group, send email to django-users-***@googlegroups.com
For more options, visit this group at http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---
z0ltan
2007-04-24 02:28:14 UTC
Permalink
Post by Malcolm Tredinnick
[...]
Post by z0ltan
and then navigate to the child directories from thence.
Apparently it was using "/" as the root directory even though mine was
\<whatever path!>", it worked fine. Am planning to raise a new ticket
on this one... thanks again for the help!
Please always try to search existing tickets, including closed ones,
before doing this (opening a new ticket). In this case, you will
hopefulyl discover that the problem has been reported and was fixed
shortly after the 0.96 release.
Regards,
Malcolm
Thanks for the suggestion Malcolm... I agree I didn't check the SVN
repositories either. I just used the plain old download section on the
main site. Hopefully they will change that as well.

Regards,

Timmy.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-***@googlegroups.com
To unsubscribe from this group, send email to django-users-***@googlegroups.com
For more options, visit this group at http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

z0ltan
2007-04-23 04:20:59 UTC
Permalink
robin_percy,

Many thanks for pointing out the defect! It was just like you had
said, the example worked fine with Django 0.96! However, an
interesting fact I noticed was that
Django 0.96's installer wouldn't install on my Windows box. It was
throwing up and error "couldn't find directory /django" and stuff
like
that! So I decided to hack around a bit and found that the problem
was
in the "setup.py" file where it tries to extract the "root directory"
and then navigate to the child directories from thence.
Apparently it was using "/" as the root directory even though mine
was
a Windows box. So when I manually changed the root directory to "c:
\<whatever path!>", it worked fine. Am planning to raise a new ticket
on this one... thanks again for the help!

Regards,

Timmy Jose.
This is most likely because you're using 0.95 instead of 0.96.  The
error is documented here:http://code.djangoproject.com/wiki/IrcFAQ#WeirdError1
Post by z0ltan
Hi folks,
     I have been bitten by the Python bug and have decided to jump
into web development using Python and what can I say, I found Django's
charms too hard to resist! But there seems to be some trouble in
paradise ... lemme explain in brief -
I setup up Django 0.95 on my system alongwith Python 2.5. Installation
went off smoothly without any errors. To test the configuration, I
started following the steps and examples given in "The Django Book".
       from django.http import HttpResponse
       from mysite.views import current_daytime
              now = datetime.datetime.now()
              html = "<html><body>The current time is %s.</body></
html>" % now
              return HttpResponse(html)
"mysite" being, of course, the project created using the command
"manage.py startproject mysite" from the ...\django\bin directory. I
started the built-in Django server using the command "manage.py
as required, I had suitably modified the 'urls.py' file in the mysite
directory).
The server runs fine. I even get the initial server screen (before
making the above modifications). However when I access the server
through the browser as "http://127.0.0.1:8001/now" ( note: the
from django.conf.urls.defaults import *
from mysite.views import current_datetime
urlpatterns = patterns('',
                (r'^now/$',current_datetime),
                )
)
However, the browser ( I tried on both IE and Mozilla Firefox ) throws
(Sorry, it's quite a bit long!!!)
<error message starts here>
AttributeError at /now/
'function' object has no attribute 'rindex'
Request Method:         GET
Request URL:    http://127.0.0.1:8001/now/
Exception Type:         AttributeError
Exception Value:        'function' object has no attribute 'rindex'
Exception Location:     C:\Python25\lib\site-packages\django-0.95.1-
py2.5.egg\django\core\urlresolvers.py in get_mod_func, line 23
Traceback (innermost last)
Switch to copy-and-paste view
    * C:\Python25\lib\site-packages\django-0.95.1-py2.5.egg\django\core
\handlers\base.py in get_response
        59. response = middleware_method(request)
        61. return response
        62.
        63. resolver = urlresolvers.RegexURLResolver(r'^/',
settings.ROOT_URLCONF)
        65. callback, callback_args, callback_kwargs =
resolver.resolve(path) ...
        66.
        67. # Apply view middleware
        69. response = middleware_method(request, callback,
callback_args, callback_kwargs)
        71. return response
      ▶ Local vars
      Variable  Value
      exceptions
      <module 'django.core.exceptions' from 'C:\Python25\lib\site-
packages\django-0.95.1-py2.5.egg\django\core\exceptions.py'>
      mail_admins
      <function mail_admins at 0x0111AE30>
      middleware_method
      <bound method AuthenticationMiddleware.process_request of
<django.contrib.auth.middleware.AuthenticationMiddleware object at
0x01143910>>
      path
      '/now/'
      request
{}>, COOKIES:{}, META:{'ALLUSERSPROFILE': 'C:\\Documents and Settings\
\All Users', 'APPDATA': 'C:\\Documents and Settings\\Timmy Jose\
\Application Data', 'CLASSPATH': 'C:\\Program Files\\Java\\jre1.5.0_06\
'C:\\WINDOWS\\system32\\cmd.exe', 'CONTENT_LENGTH': '',
'mysite.settings', 'FP_NO_HOST_CHECK': 'NO', 'GATEWAY_INTERFACE': 'CGI/
1.1', 'HOMEDRIVE': 'C:', 'HOMEPATH': '\\Documents and Settings\\Timmy
Jose', 'HTTP_ACCEPT': 'text/xml,application/xml,application/xhtml
+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5',
'HTTP_ACCEPT_CHARSET': 'ISO-8859-1,utf-8;q=0.7,*;q=0.7',
'HTTP_ACCEPT_ENCODING': 'gzip,deflate', 'HTTP_ACCEPT_LANGUAGE': 'en-
'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.3) Gecko/
20070309 Firefox/2.0.0.3', 'LOGONSERVER': '\\\\HOZEY',
'NUMBER_OF_PROCESSORS': '2', 'OS': 'Windows_NT', 'PATH': 'C:\\WINDOWS\
\system32;C:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem;C:\\Program Files\
\QuickTime\\QTSystem\\;C:\\Program Files\\Common Files\\GTK\\2.0\
'.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH', 'PATH_INFO': '/
now/', 'PCTYPE': 'PRESARIO', 'PGLOCALEDIR': 'C:\\Program Files\
\PostgreSQL\\8.2\\share\\locale', 'PLATFORM': 'MCD',
'PROCESSOR_ARCHITECTURE': 'x86', 'PROCESSOR_IDENTIFIER': 'x86 Family
15 Model 72 Stepping 2, AuthenticAMD', 'PROCESSOR_LEVEL': '15',
'PROCESSOR_REVISION': '4802', 'PROGRAMFILES': 'C:\\Program Files',
'PROMPT': '$P$G', 'QTJAVA': 'C:\\Program Files\\Java\\jre1.5.0_06\\lib\
\ext\\QTJava.zip', 'QUERY_STRING': '', 'REMOTE_ADDR': '127.0.0.1',
'8001', 'SERVER_PROTOCOL': 'HTTP/1.1', 'SERVER_SOFTWARE': 'WSGIServer/
0.1 Python/2.5', 'SESSIONNAME': 'Console', 'SONICCENTRAL': 'C:\
\Program Files\\Common Files\\Sonic Shared\\Sonic Central\\',
'SYSTEMDRIVE': 'C:', 'SYSTEMROOT': 'C:\\WINDOWS', 'TEMP': 'C:\
\DOCUME~1\\TIMMYJ~2\\LOCALS~1\\Temp', 'TMP': 'C:\\DOCUME~1\\TIMMYJ~2\
\LOCALS~1\\Temp', 'TZ': 'America/Chicago', 'USERDOMAIN': 'HOZEY',
'USERNAME': 'Timmy Jose', 'USERPROFILE': 'C:\\Documents and Settings\
\Timmy Jose', 'WINDIR': 'C:\\WINDOWS', 'wsgi.errors': <open file
'<stderr>', mode 'w' at 0x00A7F0B0>, 'wsgi.file_wrapper': <class
<socket._fileobject object at 0x00D086F8>, 'wsgi.multiprocess': False,
'http', 'wsgi.version': (1, 0)}>
      resolver
      <django.core.urlresolvers.RegexURLResolver object at 0x0114D510>
      response
      None
      self
      <django.core.handlers.wsgi.WSGIHandler object at 0x00D312F0>
      settings
      <django.conf.LazySettings object at 0x00B57790>
      urlresolvers
      <module 'django.core.urlresolvers' from 'C:\Python25\lib\site-
packages\django-0.95.1-py2.5.egg\django\core\urlresolvers.py'>
    * C:\Python25\lib\site-packages\django-0.95.1-py2.5.egg\django\core
\urlresolvers.py in resolve
       141. tried = []
       142. match = self.regex.search(path)
       144. new_path = path[match.end():]
       147. sub_match = pattern.resolve(new_path) ...
       149. tried.extend([(pattern.regex.pattern + ' ' + t) for t in
e.args[0]['tried']])
       152. return sub_match[0], sub_match[1], dict(match.groupdict(),
**sub_match[2])
       153. tried.append(pattern.regex.pattern)
      ▶ Local vars
      Variable  Value
      match
      <_sre.SRE_Match object at 0x0115C3D8>
      new_path
      'now/'
      path
      '/now/'
      pattern
      <django.core.urlresolvers.RegexURLPattern object at 0x0114DF30>
      self
      <django.core.urlresolvers.RegexURLResolver object at 0x0114D510>
      tried
      []
    * C:\Python25\lib\site-packages\django-0.95.1-py2.5.egg\django\core
\urlresolvers.py in resolve
       105. args = match.groups()
       106. # In both cases, pass any extra_kwargs as **kwargs.
       107. kwargs.update(self.default_args)
       108.
       109. try: # Lazily load self.func.
       110. return self.func, args, kwargs
       112. self.func = self.get_callback() ...
       113. return self.func, args, kwargs
       114.
       116. mod_name, func_name = get_mod_func(self.callback)
       118. return getattr(__import__(mod_name, '', '', ['']),
func_name)
      ▶ Local vars
      Variable  Value
      args
      ()
      kwargs
      {}
      match
      <_sre.SRE_Match object at 0x0115C560>
      path
      'now/'
      self
      <django.core.urlresolvers.RegexURLPattern object at 0x0114DF30>
    * C:\Python25\lib\site-packages\django-0.95.1-py2.5.egg\django\core
\urlresolvers.py in get_callback
       109. try: # Lazily load self.func.
       110. return self.func, args, kwargs
       112. self.func = self.get_callback()
       113. return self.func, args, kwargs
       114.
       116. mod_name, func_name = get_mod_func(self.callback) ...
       118. return getattr(__import__(mod_name, '', '', ['']),
func_name)
%s" % (mod_name, str(e))
%s" % (func_name, mod_name, str(e))
      ▶ Local vars
...
read more »
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-***@googlegroups.com
To unsubscribe from this group, send email to django-users-***@googlegroups.com
For more options, visit this group at http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---
Loading...