I see my error: ’auth’ is already an appname (django.contrib.auth). Using ’accnt’ works perfectly!
Thanks, again, Axel > Am 14.12.2015 um 16:32 schrieb Axel Rau <[email protected]>: > > >> Am 14.12.2015 um 16:03 schrieb knbk <[email protected] >> <mailto:[email protected]>>: >> >> authentication/urls.py: >> >> from django.conf.urls import url >> from . import views >> >> app_name = 'authentication' >> >> I thought you didn’t have an app_name, but you do have one. > I changed this after your advice. > >> In that case, the only problem was that you passed the wrong urlconf to >> reverse(). You should be able to reverse the url with: >> >> reverse('authentication:password_change') >> > I did not try this combination, but it works! Thanks! > > One last question: > > Changing this to an instance namespace would just require in urls: > > url(r'^auth/', include('authentication.urls', namespace='auth')), > > and where I reverse: > > reverse(’auth:password_change’) > > right? > > But this again gives: > > django.core.urlresolvers.NoReverseMatch: 'auth' is not a registered namespace > >> >> >> On Monday, December 14, 2015 at 3:53:24 PM UTC+1, [email protected] wrote: >> >>> Am 14.12.2015 um 15:29 schrieb knbk <[email protected] <javascript:>>: >>> >>> Could you show your full root urls.py and authentication/urls.py? >> >> urls.py: >> >> from django.conf.urls import include, url >> from django.views.generic import TemplateView >> >> # Uncomment the next two lines to enable the admin: >> from django.contrib import admin >> >> urlpatterns = ( >> url(r'^$', TemplateView.as_view(template_name='base.html')), >> url(r'^authentication/', include('authentication.urls')), >> url(r'^admin/', include(admin.site.urls)), >> ) >> >> if settings.DEBUG: >> import debug_toolbar >> urlpatterns += (url(r'^__debug__/', include(debug_toolbar.urls)),) >> >> authentication/urls.py: >> >> from django.conf.urls import url >> from . import views >> >> app_name = 'authentication' >> >> urlpatterns = [ >> url(r'^$', views.index, name='index'), >> url(r'^login/$', views.login, name='login'), >> url(r'^loggedin/$', views.loggedin, name='loggedin'), >> url(r'^logout/$', views.logout, name='logout'), >> url(r'^password/$', views.password, name='password'), >> url(r'^password_change/$', views.password_change, >> name='password_change'), >> url(r'^password_change/done/$', views.password_change_done, >> name='password_change_done'), >> url(r'^password_reset/$', views.password_reset, name='password_reset'), >> url(r'^password_reset/done/$', views.password_reset_done, >> name='password_reset_done'), >> url(r'^reset/done/$', views.password_reset_complete, >> name='password_reset_complete'), >> >> url(r'^reset/(?P<uidb64>[0-9A-Za-z]{1,13})-(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$', >> views.password_reset_confirm, >> name='password_reset_confirm'), >> url(r'^profile/$', views.profile, name='profile') >> ] >> >> Axel >> >>> >>> On Monday, December 14, 2015 at 3:22:14 PM UTC+1, [email protected] wrote: >>> Thanks for taking the time, >>> >>> >>>> Am 14.12.2015 um 14:06 schrieb knbk <[email protected] <>>: >>>> >>>> Hi Axel, >>>> >>>> An installed application and a registered URL namespace are two distinct >>>> concepts. A URL namespace can only be defined by setting the app_name >>>> attribute in your urlconf. In this case, you haven’t set a URL namespace >>>> for your authentication app, so your urls are not namespaced. >>> OK. (I misunderstood the 1.9 docu as this would be required only with >>> instance namespaces). >>>> >>>> Also, the urlconf parameter to reverse() should point to the root urlconf, >>>> not to the urlconf in which your current url is defined. Since it defaults >>>> to the root urlconf defined in your project, it's easiest to omit it in >>>> most cases. If you don’t, and use 'authentication.urls' as your root >>>> urlconf, the generated url will miss the 'authentication/' part of your >>>> url. >>> I understand. >>>> >>>> >>>> To reverse the password_change url, simply use this: >>>> >>>> reverse(‚password_change') >>> Making both changes gives: >>> django.core.urlresolvers.NoReverseMatch: Reverse for 'password_change' >>> with arguments '()' and keyword arguments '{}' not found. 0 pattern(s) >>> tried: [] >>> >>> I then tried to reference the views directly instead of strings: >>> >>> from . import views >>> reverse(views.password_change), >>> >>> with views.py containing: >>> >>> class PasswordChangeView(LoginRequiredMixin, AuthDecoratorsMixin, >>> WithCurrentSiteMixin, FormView): >>> ... >>> >>> password_change = PasswordChangeView.as_view() >>> >>> and got; >>> >>> django.core.urlresolvers.NoReverseMatch: Reverse for >>> 'authentication.views.PasswordChangeView' with arguments '()' and keyword >>> arguments '{}' not found. 0 pattern(s) tried: [] >>> >>> Axel >>> >>> >>>> >>>> Marten >>>> >>>> >>>> On Monday, December 14, 2015 at 1:37:56 PM UTC+1, [email protected] wrote: >>>> In my root url, I have: >>>> >>>> url(r'^authentication/', include('authentication.urls')), >>>> >>>> in authentication/urls.py, I have no app_name declared. >>>> >>>> In a module in authentication, I have >>>> >>>> from django.core.urlresolvers import reverse >>>> >>>> from django.apps import apps >>>> print('authentication installed? ' + str(apps.is >>>> <http://apps.is/>_installed('authentication'))) >>>> >>>> >>>> reverse('authentication:password_change',urlconf='authentication.urls') >>>> >>>> and receive >>>> django.core.urlresolvers.NoReverseMatch: 'authentication' is not a >>>> registered namespace >>>> while the above debug print gives >>>> authentication installed? True >>>> >>>> What am I doing wrong here? >>>> >>>> Please advice, >>>> Axel >>>> — >>>> PGP-Key:29E99DD6 ☀ +49 160 9945 7889 ☀ computing @ chaos claudius >>>> >>>> >>>> -- >>>> You received this message because you are subscribed to the Google Groups >>>> "Django users" group. >>>> To unsubscribe from this group and stop receiving emails from it, send an >>>> email to [email protected] <>. >>>> To post to this group, send email to [email protected] <>. >>>> Visit this group at https://groups.google.com/group/django-users >>>> <https://groups.google.com/group/django-users>. >>>> To view this discussion on the web visit >>>> https://groups.google.com/d/msgid/django-users/fc585533-0cb4-4419-8944-b38cbf4b472c%40googlegroups.com >>>> >>>> <https://groups.google.com/d/msgid/django-users/fc585533-0cb4-4419-8944-b38cbf4b472c%40googlegroups.com?utm_medium=email&utm_source=footer>. >>>> For more options, visit https://groups.google.com/d/optout >>>> <https://groups.google.com/d/optout>. >>> >>> --- >>> PGP-Key:29E99DD6 ☀ +49 160 9945 7889 ☀ computing @ chaos claudius >>> >>> >>> -- >>> You received this message because you are subscribed to the Google Groups >>> "Django users" group. >>> To unsubscribe from this group and stop receiving emails from it, send an >>> email to [email protected] <javascript:>. >>> To post to this group, send email to [email protected] >>> <javascript:>. >>> Visit this group at https://groups.google.com/group/django-users >>> <https://groups.google.com/group/django-users>. >>> To view this discussion on the web visit >>> https://groups.google.com/d/msgid/django-users/e8700750-d783-4636-926e-6a73c2fb6f6b%40googlegroups.com >>> >>> <https://groups.google.com/d/msgid/django-users/e8700750-d783-4636-926e-6a73c2fb6f6b%40googlegroups.com?utm_medium=email&utm_source=footer>. >>> For more options, visit https://groups.google.com/d/optout >>> <https://groups.google.com/d/optout>. >> >> --- >> PGP-Key:29E99DD6 ☀ +49 160 9945 7889 ☀ computing @ chaos claudius >> >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Django users" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected] >> <mailto:[email protected]>. >> To post to this group, send email to [email protected] >> <mailto:[email protected]>. >> Visit this group at https://groups.google.com/group/django-users >> <https://groups.google.com/group/django-users>. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/django-users/11023179-3040-4f1d-b19b-37670b4bed71%40googlegroups.com >> >> <https://groups.google.com/d/msgid/django-users/11023179-3040-4f1d-b19b-37670b4bed71%40googlegroups.com?utm_medium=email&utm_source=footer>. >> For more options, visit https://groups.google.com/d/optout >> <https://groups.google.com/d/optout>. > > --- > PGP-Key:29E99DD6 ☀ +49 160 9945 7889 ☀ computing @ chaos claudius > > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected] > <mailto:[email protected]>. > To post to this group, send email to [email protected] > <mailto:[email protected]>. > Visit this group at https://groups.google.com/group/django-users > <https://groups.google.com/group/django-users>. > To view this discussion on the web visit > https://groups.google.com/d/msgid/django-users/632B8326-2D9C-493E-BB76-31120FDDEE61%40Chaos1.DE > > <https://groups.google.com/d/msgid/django-users/632B8326-2D9C-493E-BB76-31120FDDEE61%40Chaos1.DE?utm_medium=email&utm_source=footer>. > For more options, visit https://groups.google.com/d/optout > <https://groups.google.com/d/optout>. --- PGP-Key:29E99DD6 ☀ +49 160 9945 7889 ☀ computing @ chaos claudius -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/F55AB604-901F-43B6-8153-82DFA57FF7D6%40Chaos1.DE. For more options, visit https://groups.google.com/d/optout.

