#300 closed defect (invalid)
ImportError in simple setup
Reported by: | Owned by: | Adrian Holovaty | |
---|---|---|---|
Component: | Core (Other) | Version: | |
Severity: | normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
First, let me just say that I might be doing something wrong and that this is not a bug. But after talking to some people on IRC it seems that it should work, at least no-one said "oh, you cant do that".
Reproduce what Im doing:
$ django-admin.py startproject he $ export DJANGO_SETTINGS_MODULE=he.settings.main
Then create a file:
$ cat > he/foo.py from django.utils.httpwrappers import HttpResponse def bar(request): return HttpResponse("foobar") ^D $ python -c 'import he.foo; he.foo.bar()' Traceback (most recent call last): File "<string>", line 1, in ? TypeError: bar() takes exactly 1 argument (0 given)
Obviously Python can find the file. Then put this into he/settings/urls/main.py:
(r'^$', include('he.foo.bar')),
Then run "django-admin.py runserver" and point the browser to see this error:
Traceback (most recent call last): File "/usr/lib/python2.3/site-packages/django/core/handlers/base.py", line 56, in get_response callback, param_dict = resolver.resolve(path) File "/usr/lib/python2.3/site-packages/django/core/urlresolvers.py", line 64, in resolve sub_match = pattern.resolve(new_path) File "/usr/lib/python2.3/site-packages/django/core/urlresolvers.py", line 62, in resolve for pattern in self.url_patterns: File "/usr/lib/python2.3/site-packages/django/core/urlresolvers.py", line 79, in _get_url_patterns self.url_patterns = self.urlconf_module.urlpatterns File "/usr/lib/python2.3/site-packages/django/core/urlresolvers.py", line 74, in _get_urlconf_module self.urlconf_module = __import__(self.urlconf_name, '', '', ['']) ImportError: No module named bar
Change History (3)
comment:1 by , 19 years ago
comment:3 by , 19 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
include()
is for including other URL confs; don't use it for a simple view (see NewbieMistakes). Please don't use the ticket system for support requests; ask on the mailing list or on IRC.
Forgot to put in there that Ive properly edited he/settings/main.py and changed to sqlite3 etc, and run "django-admin.py init".