﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
240	get_callback() improvements	maurycy	Jacob	"The problem was:

{{{
[maurycy@localhost ~]$ grep -A 2 INSTALLED_APPS session/settings/main.py

INSTALLED_APPS = (

    'session.apps.session',

)

[maurycy@localhost ~]$ cat session/settings/urls/main.py

from django.conf.urls.defaults import *



urlpatterns = patterns('',

    (r'^session/', include('session.apps.session.urls.session')),

)

[maurycy@localhost ~]$ cat session/apps/session/urls/session.py

from django.conf.urls.defaults import *



urlpatterns = patterns('',

    (r'^login/?$', 'session.apps.session.views.login'),

    (r'^logout/?$', 'session.apps.session.views.logout'),

)

[maurycy@localhost ~]$ ls -1 session/apps/session/views/*.py

session/apps/session/views/__init__.py

session/apps/session/views/login.py

session/apps/session/views/logout.py

[maurycy@localhost ~]$ export DJANGO_SETTINGS_MODULE='session.settings.main'

[maurycy@localhost ~]$ django-admin.py runserver

Starting server on port 8000 with settings module 'session.settings.main'.

Go to http://127.0.0.1:8000/ for Django.

Quit the server with CONTROL-C (Unix) or CTRL-BREAK (Windows).

[31/Jul/2005 00:32:03] ""GET /session/login HTTP/1.1"" 302 0

[31/Jul/2005 00:32:03] ""GET /session/login/ HTTP/1.1"" 500 883



Where http://localhost:8000/session/login returns the exception:



There's been an error:



Traceback (most recent call last):



  File ""/usr/lib/python2.4/site-packages/django/core/handlers/base.py"", line 57, in get_response

    callback, param_dict = resolver.resolve(path)



  File ""/usr/lib/python2.4/site-packages/django/core/urlresolvers.py"", line 81, in resolve

    match = pattern.search(app_path)



  File ""/usr/lib/python2.4/site-packages/django/core/urlresolvers.py"", line 59, in search

    sub_match = pattern.search(new_path)



  File ""/usr/lib/python2.4/site-packages/django/core/urlresolvers.py"", line 34, in search

    self.func = self.get_callback()



  File ""/usr/lib/python2.4/site-packages/django/core/urlresolvers.py"", line 42, in get_callback

    raise ViewDoesNotExist, ""Tried %s. Error was: %s"" % (self.callback, str(e))



ViewDoesNotExist: Tried session.apps.session.views.login. Error was: 'module' object has no attribute 'login'
}}}

Discussion:

{{{
05:30 < mmarshall> (r'^login/?$', 'session.apps.session.views.login.login')
05:31 < mmarshall> Try that.
05:31 < maurycypw> ugh?
05:31 < maurycypw> ugly, but works.
05:31 < mmarshall> hehe
05:31 < maurycypw> why it works?
05:31 -!- slightlyoff [~alex@12.180.45.190] has joined #django
05:32 < mmarshall> Django must need a function name.
05:32 < mmarshall> All you were giving it was a module name.
05:32 < maurycypw> eh. it should be fixed
05:32 < maurycypw> next ticket, please!
05:32 < mmarshall> I guess that the error was so unhelpful because it only
                   looked for attributes that were functions.
05:33 < mmarshall> In this case, you had an attribute named 'login', but it was
                   another module.
05:33 < mmarshall> And yes, it should be fixed :D
}}}"	defect	closed	Core (Other)		trivial	fixed			Ready for checkin	0	0	0	0	0	0
