Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reset password in Django

Tags:

python

django

I have view this tutorial https://www.youtube.com/watch?v=z6pXNf2SzQQ that explain how to send mail to reset password, I have follow all steps but I have the same error always: No module named 'my_app.views.django'; 'my_app.views' is not a package. For this case my_app = melomanos. I have all templates for Django reset password in my site templates folder.

The complete site root is:

root of my app

The error that shows is: I know I have a missconfigured urls but I don't understand how I can configure correctly. Thanks for your cooperation.

ImportError at /resetpassword/
No module named 'melomanos.views.django'; 'melomanos.views' is not a package
Request Method: GET
Request URL:    http://localhost/resetpassword/
Django Version: 1.8.2
Exception Type: ImportError
Exception Value:    
No module named 'melomanos.views.django'; 'melomanos.views' is not a package
Exception Location: C:\Python34\lib\importlib\__init__.py in import_module, line 109
Python Executable:  C:\Python34\python.exe
Python Version: 3.4.3
Python Path:['c:\\labsoft',
'C:\\Python34\\lib\\site-packages\\psycopg2-2.6-py3.4-win-amd64.egg',
'C:\\Windows\\SYSTEM32\\python34.zip',
'C:\\Python34\\DLLs',
'C:\\Python34\\lib',
'C:\\Python34',
'C:\\Python34\\lib\\site-packages',
'labsoft/melomanos',
'/melomanos']

here is the codes:

melomanos\urls.py

from django.conf.urls import patterns, url, include
from django.views.generic.base import TemplateView
from django.contrib import admin
from .views import Buscar_view
admin.autodiscover()

urlpatterns = patterns('melomanos.views',
                   url(r'^admin/', include(admin.site.urls)),
                   url(r'^$','trabajos_all_view',name='url_index'),
                   url(r'^register/$','register_view',name='vista_registro'),
                   url(r'^login/$','login_view',name='vista_login'),
                   url(r'^logout/$','logout_view',name='vista_logout'),
                   url(r'^perfil/$','registro_view',name='vista_perfil'),
                   url(r'^publicar/$','trabajomusical_view', name='vista_publicar'),
                   url(r'^trabajos/$','trabajos_view',name='vista_trabajos'),
                   url(r'^trabajo/(?P<id_trabajo>.*)/$','solo_trabajo_view', name='vista_trabajo'),
                   url(r'^buscar/$',Buscar_view.as_view(),name='vista_buscar'),
                   url('', include('django.contrib.auth.urls')),
                   url(r'^resetpassword/passwordsent/$', 'django.contrib.auth.views.password_reset_done', name='password_reset_done'),
                   url(r'^resetpassword/$', 'django.contrib.auth.views.password_reset', name="reset_password"),
                   url(r'^reset/(?P<uidb36>[0-9A-Za-z]+)-(?P<token>,+)/$', 'django.contrib.auth.views.password_reset_confirm'),
                   url(r'^reset/done/$', 'django.contrib.auth.views.password_reset_complete'),
                   )

The link at the login page:

<p>Forgot your password?<a href="/resetpassword/">Reset Password</a></p>

settings.py

    INSTALLED_APPS = (
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'melomanos',
    )
like image 584
Jairo Betancourt Avatar asked Feb 09 '23 22:02

Jairo Betancourt


1 Answers

On melomanos\urls.py you are using url prefix.

urlpatterns = patterns('melomanos.views',
    url(r'^resetpassword/$', 'django.contrib.auth.views.password_reset', name="reset_password"),
)

So /resetpassword/ is calling melomanos.views.django.contrib.auth.views.password_reset instead of django.contrib.auth.views.password_reset

For reset password view removing the prefix will solve this issue.

You may remove resetpassword from prefixed block and later add it without prefix like

urlpatterns += patterns('',
    url(r'^resetpassword/$', 'django.contrib.auth.views.password_reset', name="reset_password"),
)
like image 70
moonstruck Avatar answered Feb 12 '23 10:02

moonstruck