Opened 14 years ago

Closed 14 years ago

Last modified 12 years ago

#300 closed defect (invalid)

ImportError in simple setup

Reported by: henrik@… 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


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:

 $ startproject he
 $ export DJANGO_SETTINGS_MODULE=he.settings.main

Then create a file:

 $ cat > he/
 from django.utils.httpwrappers import HttpResponse
 def bar(request):
     return HttpResponse("foobar")

 $ python -c 'import;'
 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/

 (r'^$', include('')),

Then run " runserver" and point the browser to see this error:

 Traceback (most recent call last):

  File "/usr/lib/python2.3/site-packages/django/core/handlers/", line 56, in get_response
    callback, param_dict = resolver.resolve(path)

  File "/usr/lib/python2.3/site-packages/django/core/", line 64, in resolve
    sub_match = pattern.resolve(new_path)

  File "/usr/lib/python2.3/site-packages/django/core/", line 62, in resolve
    for pattern in self.url_patterns:

  File "/usr/lib/python2.3/site-packages/django/core/", line 79, in _get_url_patterns
    self.url_patterns = self.urlconf_module.urlpatterns

  File "/usr/lib/python2.3/site-packages/django/core/", line 74, in _get_urlconf_module
    self.urlconf_module = __import__(self.urlconf_name, '', '', [''])

 ImportError: No module named bar

Change History (3)

comment:1 Changed 14 years ago by henrik@…

Forgot to put in there that Ive properly edited he/settings/ and changed to sqlite3 etc, and run " init".

comment:2 Changed 14 years ago by anonymous

Seems that this also is the case with PostgreSQL.

comment:3 Changed 14 years ago by Jacob

Resolution: invalid
Status: newclosed

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.

Note: See TracTickets for help on using tickets.
Back to Top