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. On Apr 22, 10:53 pm, robin_percy <[EMAIL PROTECTED]> wrote: > 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 > > On Apr 22, 10:25 am, z0ltan <[EMAIL PROTECTED]> wrote: > > > 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 > > ... > > 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 [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---

