Django admin: add widget link broken

74 views Asked by At

Not sure how I did this and have searched everywhere for a solution, but can not find one. I have managed to either install incorrectly or break my installation of a default Django 1.3.1 admin project so that the add widget is rendered with a broken link.

default auth user properties page's add widget

The above link should be rendered as http://mynode.com/admin/auth/group/add/, but is being rendered as http://mynode.com/$auth/group/add/ instead. This is consistent on every page were the add widget is displayed. Any ideas what I have broken or what is missing from my settings?

1

There are 1 answers

0
pedwards On BEST ANSWER

Ok, very interesting... found it and feeling foolish now.

I put some prints throughout the Django admin and core code and discovered that my problem was coming from within the call...

`related_url = reverse('admin:%s_%s_add' % info, current_app=self.admin_site.name)`

found inside django/contrib/admin/widgets.py. reverse() in an effort to craft the URL for my projects link, iterates through the resolver.namespace_dict looking for something that will match the namespace or current app, in this case admin. A quick check in my url.py file found the following entry...

( r'^$', include(admin.site.urls) ),

I guess I had added this entry in an attempt to do something (which I've completely forgotten... Dooh!) and this caused reverse() to render my widgets link incorrectly. :(

Update I remember now. I was trying to add a root site handler. mysite.com/ This works but the trick is to make sure this entry is after

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

in your urlpatterns.