Made a separate application for user authorization. After authorization I want to send it to another application. I do it like this:

return reverse('/accountant'); 

or

 return reverse('/balance'); 

or

 return reverse('accountant:balance'); 

or

 return redirect("/accountant"); 

To which I get an error: Mistake

What am I doing wrong, and how to do it?

For accountant urls.py application:

 urlpatterns = [ url(r'^$', views.balance, name='balance'), url(r'^account/(?P<pk>[0-9]+)/$', views.account_edit, name='account_edit'), url(r'^category/(?P<pk>[0-9]+)/$', views.category_view, name='category_view'), ] 

for auth_page application:

 urlpatterns = [ url(r'', views.auth_page, name='auth_page'), ] 

for the whole site:

 urlpatterns = [ url(r'^admin/', admin.site.urls), url(r'^accountant/', include('accountant.urls')), url(r'^', include('auth_page.urls')), ] 

Switch to copy-and-paste view:

 Environment: Request Method: POST Request URL: http://127.0.0.1:8000/accountant Django Version: 1.9.8 Python Version: 3.5.0 Installed Applications: ['django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'accountant', 'auth_page'] Installed Middleware: ['django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware'] Traceback: File "D:\Program Files\Python\Python35-32\lib\site-packages\django\core\handlers\base.py" in get_response 149.response = self.process_exception_by_middleware(e, request) File "D:\Program Files\Python\Python35-32\lib\site-packages\django\core\handlers\base.py" in get_response 147. response = wrapped_callback(request, *callback_args, **callback_kwargs) File "C:\Users\Rail\Documents\Django\Assistant\auth_page\views.py" in auth_page 25. return reverse("/accountant"); File "D:\Program Files\Python\Python35-32\lib\site-packages\django\core\urlresolvers.py" in reverse 600. return force_text(iri_to_uri(resolver._reverse_with_prefix(view, prefix, *args, **kwargs))) File "D:\Program Files\Python\Python35-32\lib\site-packages\django\core\urlresolvers.py" in _reverse_with_prefix 508. (lookup_view_s, args, kwargs, len(patterns), patterns)) Exception Type: NoReverseMatch at /accountant Exception Value: Reverse for '/accountant' with arguments '()' and keyword arguments '{}' not found. 0 pattern(s) tried: [] 

Fixed urls.py for the whole site and got:

 urlpatterns = [ url(r'^admin/', admin.site.urls), url(r'^accountant/', include('accountant.urls')), url(r'^$', include('auth_page.urls')), ] 

New bug

  • 1) I still do not understand what kind of error it is, but just in case, you can urls.py both applications (from which we are moving and which we are switching to, you can remove the irrelevant)? / 2) Can “Switch to copy-and-paste view” and full Traceback here? (via question editing) - andreymal
  • python manage.py check what shows? - Igor
  • WARNINGS:?: (Urls.W001) Your URL pattern '^ $' uses a regex ending with a '$'. Remove the dollar from the regex to avoid problems including URLs. System check identified 1 issue (0 silenced). After deleting, $ says: System check identified no issues (0 silenced). - R.Mazgutov

0