Repository: django-cms/django-cms

Issue:
Can't delete user (v3.0)
NoReverseMatch at /nl/admin/auth/user/
Reverse for 'cms_usersettings_change' with arguments '(1,)' and keyword arguments '{}' not found.

Can't delete user (v3.0)
NoReverseMatch at /nl/admin/auth/user/
Reverse for 'cms_usersettings_change' with arguments '(1,)' and keyword arguments '{}' not found.



Discussion:
what was the url this error occured?
what version of django?

Django==1.5.1

URL = /nl/admin/auth/user/.

mmh works for me.

settings?

oh and urls.py

``` python
urlpatterns = i18n_patterns('',
                            (r'^facebook/', include('django_facebook.urls')),
                            (r'^accounts/', include('userena.urls')),

                            url(r'^admin/', include(admin.site.urls)),

                            url(r'^', include('cms.urls')),
)
```

Traceback: http://dpaste.com/1271522/.

this is newest develop branch?

Have you overwritten the user model?

Yes, newest develop. No, not overwritten the user model.

I have the same problem so let me share some more info. The user cant be deleted only if he has user settings entry set. The error is:

```
File ".../env/lib/python2.7/site-packages/django/core/urlresolvers.py", line 416, in _reverse_with_prefix
    "arguments '%s' not found." % (lookup_view_s, args, kwargs))
NoReverseMatch: Reverse for 'cms_usersettings_change' with arguments '(2L,)' and keyword arguments '{}' not found.
```

The problem could be on this [line](https://github.com/divio/django-cms/blob/develop/cms/admin/settingsadmin.py#L32) where on return `get_urls` should instead append its patterns to ModelAdmin's  patterns like this:

```
return urlpatterns + super(SettingsAdmin, self).get_urls()
```

Alternative is to use two patterns since optional parameters are [not supported](http://stackoverflow.com/a/1352841/1247955) in url reversal:

```
urlpatterns = patterns(
    '',
    url(r'^$',
        wrap(self.change_view),
        name='%s_%s_change' % info),
    url(r'^(.+)/$',
        wrap(self.change_view),
        name='%s_%s_change' % info),
)
return urlpatterns
```

what was the url this error occured?
what version of django?

Django==1.5.1

URL = /nl/admin/auth/user/.

mmh works for me.

settings?

oh and urls.py

``` python
urlpatterns = i18n_patterns('',
                            (r'^facebook/', include('django_facebook.urls')),
                            (r'^accounts/', include('userena.urls')),

                            url(r'^admin/', include(admin.site.urls)),

                            url(r'^', include('cms.urls')),
)
```

Traceback: http://dpaste.com/1271522/.

this is newest develop branch?

Have you overwritten the user model?

Yes, newest develop. No, not overwritten the user model.

I have the same problem so let me share some more info. The user cant be deleted only if he has user settings entry set. The error is:

```
File ".../env/lib/python2.7/site-packages/django/core/urlresolvers.py", line 416, in _reverse_with_prefix
    "arguments '%s' not found." % (lookup_view_s, args, kwargs))
NoReverseMatch: Reverse for 'cms_usersettings_change' with arguments '(2L,)' and keyword arguments '{}' not found.
```

The problem could be on this [line](https://github.com/divio/django-cms/blob/develop/cms/admin/settingsadmin.py#L32) where on return `get_urls` should instead append its patterns to ModelAdmin's  patterns like this:

```
return urlpatterns + super(SettingsAdmin, self).get_urls()
```

Alternative is to use two patterns since optional parameters are [not supported](http://stackoverflow.com/a/1352841/1247955) in url reversal:

```
urlpatterns = patterns(
    '',
    url(r'^$',
        wrap(self.change_view),
        name='%s_%s_change' % info),
    url(r'^(.+)/$',
        wrap(self.change_view),
        name='%s_%s_change' % info),
)
return urlpatterns
```


Resolving patch:
diff --git a/cms/admin/settingsadmin.py b/cms/admin/settingsadmin.py
--- a/cms/admin/settingsadmin.py
+++ b/cms/admin/settingsadmin.py
@@ -28,12 +28,15 @@ def wrapper(*args, **kwargs):
             url(r'^$',
                 wrap(self.change_view),
                 name='%s_%s_change' % info),
+            url(r'^(.+)/$',
+                wrap(self.change_view),
+                name='%s_%s_change' % info),
         )
         return urlpatterns
 
     @csrf_protect_m
     @transaction.commit_on_success
-    def change_view(self, request):
+    def change_view(self, request, id=None):
         model = self.model
         try:
             obj = model.objects.get(user=request.user)


Test patch: