[Answered ]-Attributeerror: 'module' object has no attribute 'register_success'

1👍

You don’t need to add all urls under reg/urls.py individually into site/urls.py as url(r'^reg/', include('reg.urls')) already does that automatically for you.

Here is the corrected version of urlpatterns defined in sites/urls.py:

from django.conf.urls import patterns

urlpatterns = patterns(
    "",
    (r'^admin/', admin.site.urls),    
    (r'^aps/', include('aps.urls'),
    (r'^mail/', include('mail.urls'),
    (r'^reg/', include('reg.urls'),
)

and reg/urls.py:

from django.conf.urls import patterns

urlpatterns = patterns(
    "",
    url(r'^login/$', views.login, name='login'),
    url(r'^auth/$', views.auth_view, name='auth_view'),
    url(r'^loggedin/$', views.loggedin, name='loggedin'),
    url(r'^invalid/$', views.invalid_login, name='invalid_login'),
    url(r'^register/$', views.register_user, name='register_user'),
    url(r'^logout/$', views.logout, name='logout'),
    url(r'^register_success/$', views.register_success, name='register_success'),
)

1👍

in your site/urls.py :

from django.contrib.auth import views as auth_views 
from django.contrib.auth import views

When your code is trying to access views.register_success you’re trying to access register_success inside django.contrib.auth, hence the error.

You’ll get the same error when the code will try to access the other views : it simply searches at the wrong place!

Just correct the import :

from reg import views

EDIT : Even if it doesn’t explain the cause of your current problem, ozgur’s answer gives better practices, you should really look at it and follow his advice.

Leave a comment