Discussion:
[importError] No module name py. Newby
Snirp
2006-12-05 14:24:18 UTC
Permalink
Hi there,

I am starting off with django and decided to stick with the "django
book"

The webserver initiates just fine, and i made the first example: return
current time when requested the URL: /now/

It returns the following error when requesting the url:



Traceback (most recent call last):
File "d:\webdev\python\django\core\handlers\base.py" in get_response
65. callback, callback_args, callback_kwargs = resolver.resolve(path)
File "d:\webdev\python\django\core\urlresolvers.py" in resolve
145. for pattern in self.urlconf_module.urlpatterns:
File "d:\webdev\python\django\core\urlresolvers.py" in
_get_urlconf_module
161. self._urlconf_module = __import__(self.urlconf_name, '', '',
[''])

ImportError at /now/
No module named py



The path to d:\webdev\python is just fine and the welcome screen
displays just fine.


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
Snirp
2006-12-05 15:03:02 UTC
Permalink
ok, made a typo, but i am still not out of the woods...

I now have a AttributeError at /now/ error

Exception Value: 'function' object has no attribute 'rindex'

Traceback (most recent call last):
File "d:\webdev\python\django\core\handlers\base.py" in get_response
65. callback, callback_args, callback_kwargs = resolver.resolve(path)
File "d:\webdev\python\django\core\urlresolvers.py" in resolve
147. sub_match = pattern.resolve(new_path)
File "d:\webdev\python\django\core\urlresolvers.py" in resolve
112. self.func = self.get_callback()
File "d:\webdev\python\django\core\urlresolvers.py" in get_callback
116. mod_name, func_name = get_mod_func(self.callback)
File "d:\webdev\python\django\core\urlresolvers.py" in get_mod_func
23. dot = callback.rindex('.')

AttributeError at /now/
'function' object has no attribute 'rindex'


The urls.py looks like this:


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

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


The current_datetime function is defined in timeview.py in the same
folder


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
tonetheman
2006-12-05 15:14:52 UTC
Permalink
I think unless you are using the stuff from the bleeding edge the
second object in the tuple should be a string. Check out this doc
(http://www.djangoproject.com/documentation/url_dispatch/) and see how
they did the urls.py and see if that works better.

Something like this...

urlpatterns = patterns('', ('/something or other',
'mysite.timeview.current_datetime'),)

Tone


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
Snirp
2006-12-05 16:16:09 UTC
Permalink
Great Tone! This works.

Just one thing... you are supposed to show me the general direction,
not to solve my problems with complete code included.

How will i ever learn? ;-)

If you were a pretty girl, i'd kiss you. Come to speak of it, I would
do just that with any pretty girl.

Well you get the general idea, i am greatful.
Post by tonetheman
I think unless you are using the stuff from the bleeding edge the
second object in the tuple should be a string. Check out this doc
(http://www.djangoproject.com/documentation/url_dispatch/) and see how
they did the urls.py and see if that works better.
Something like this...
urlpatterns = patterns('', ('/something or other',
'mysite.timeview.current_datetime'),)
Tone
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
Waylan Limberg
2006-12-05 15:24:01 UTC
Permalink
Post by Snirp
Hi there,
I am starting off with django and decided to stick with the "django
book"
The webserver initiates just fine, and i made the first example: return
current time when requested the URL: /now/
File "d:\webdev\python\django\core\handlers\base.py" in get_response
65. callback, callback_args, callback_kwargs = resolver.resolve(path)
File "d:\webdev\python\django\core\urlresolvers.py" in resolve
File "d:\webdev\python\django\core\urlresolvers.py" in
_get_urlconf_module
161. self._urlconf_module = __import__(self.urlconf_name, '', '',
[''])
ImportError at /now/
No module named py
I have a sneaking suspicion that you are trying to `import
somefile.py`. When importing in your python code, the `.py` file
extension is assumed, so leave if off: `import somefile`.

If that's not it, post your urls.py file here so we can see what may
be causing the problem.
Post by Snirp
The path to d:\webdev\python is just fine and the welcome screen
displays just fine.
--
----
Waylan Limberg
***@gmail.com

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
Snirp
2006-12-05 16:07:48 UTC
Permalink
I was doing just that in the original post. I fixed that and got the
error in the second post. I am going to give it another try now
Post by Waylan Limberg
Post by Snirp
Hi there,
I am starting off with django and decided to stick with the "django
book"
The webserver initiates just fine, and i made the first example: return
current time when requested the URL: /now/
File "d:\webdev\python\django\core\handlers\base.py" in get_response
65. callback, callback_args, callback_kwargs = resolver.resolve(path)
File "d:\webdev\python\django\core\urlresolvers.py" in resolve
File "d:\webdev\python\django\core\urlresolvers.py" in
_get_urlconf_module
161. self._urlconf_module = __import__(self.urlconf_name, '', '',
[''])
ImportError at /now/
No module named py
I have a sneaking suspicion that you are trying to `import
somefile.py`. When importing in your python code, the `.py` file
extension is assumed, so leave if off: `import somefile`.
If that's not it, post your urls.py file here so we can see what may
be causing the problem.
Post by Snirp
The path to d:\webdev\python is just fine and the welcome screen
displays just fine.
--
----
Waylan Limberg
--~--~---------~--~----~------------~-------~--~----~
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...