Monday, October 28, 2013

Re: (3rd party app) How to safely reverse a custom user model admin url?

No takers? Maybe I am giving everyone a case of TL;DR.

More simply, how do I put {{ app_label }}_{{ model_name }}_changelist in a template for a custom auth_user model without knowing the details of said model? 

I am guessing I don't want to refer to settings.auth_user_model in the template. It feels like the only way is to use the tag in that case and instead somehow call the changelist function (wherever that is) in the view. If so, anyone know how to do that?

On Friday, October 25, 2013 7:39:59 PM UTC-5, Ivan VenOsdel wrote:
My project uses a custom user model and I am trying to use a 3rd party app that uses the Reversing Admin URLs technique to enhance my administration interface.

However problems arise when the app tries to make use of the url template tag to do a reverse lookup on the auth user ModelAdmin instance. When 'auth_user_(something)' is referenced directly the template will produce a NoReverseMatch error.

I would like to produce a patch for the package maintainer but I am unsure of how to reference the stand in user model without tying the app to my project or doing something kludgy that goes against the spirit of the django url tag.

The specific app I have been working with is the django-blog-zinnia application. Zinnia is using the following technique to provide changeset details in a generic way through the Django admin.

The problem occurs when it tries to reverse auth_user_* when the site is using a custom user model. For Zinnia it occurs in the following places.

I have already reported this issue to the Zinnia maintainer however I would like to provide something more meaningful in the way of a patch. Replacing the auth_user part of the offending lines with 'myapp_customuser' will fix the issue for me but how do I do something that is viable for a 3rd party application?

Thanks!

--
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 django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/64ea3064-aa5f-41f6-b02e-58e2db49798f%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment