Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change url for sessions #8

Closed
elnappo opened this issue Apr 27, 2014 · 1 comment
Closed

change url for sessions #8

elnappo opened this issue Apr 27, 2014 · 1 comment

Comments

@elnappo
Copy link

elnappo commented Apr 27, 2014

in urls.py there are two views:

  • account/sessions/
  • sessions/(?P\w+)/delete/

shouldn't it be?:

  • account/sessions/
  • account/sessions/(?P\w+)/delete/

I tried to change the url for the views with

from user_sessions.views import SessionListView, SessionDeleteView

urlpatterns = patterns('',
    url(
        regex=r'^accounts/sessions/$',
        view=SessionListView.as_view(),
        name='session_list',
    ),
    url(
        regex=r'^accounts/sessions/(?P<pk>\w+)/delete/$',
        view=SessionDeleteView.as_view(),
        name='session_delete',
    ),
)

but I get a

NoReverseMatch at /accounts/sessions/ 
Exception Value: 'user_sessions' is not a registered namespace
<form method="post" action="{% url 'user_sessions:session_delete' object.pk %}">

What can i do to prevent that? This makes the urls very inflexible. Also maybe you can change the default urls to:

  • sessions/
  • sessions/(?P\w+)/delete/

In this case you can simply do:

url(r'^account/', include('user_sessions.urls', 'user_sessions')),

Thank you

@Bouke
Copy link
Collaborator

Bouke commented Apr 27, 2014

Hi @elnappo I guess you're right about the inconsistency in the URLs and that should be fixed. If you want to provide your own URLs instead of including the urlpatterns provided by the package, make sure you include the namespace user_sessions as well. Otherwise you'll get the error message as you've listed above. The solution would be something along the lines of wrapping the urlpatterns with an include.

@Bouke Bouke closed this as completed in 0a527a7 Apr 27, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants