Hi guys

I must say I hit this issue a few months ago (I have more than one admin 
app living side by side). It was confusing, when reversing a URL name, 
whether to change 'admin' in a string like this `'admin:%s_%s_change'`, or 
use `current_app=self.admin_site.name`.

Since I don't like hardcoded strings and I (or someone using my 
code) would probably get confused over this at a later point, I created a 
utility function that perhaps may be useful for someone else and/or to 
clarify the problem:

def get_admin_view_url_name(model, view, admin_site=None):
admin_site = admin_site or 'admin'

# TODO: replace `module_name` with `model_name` when using Django 1.6
return '%s:%s_%s_%s' % (
admin_site,
model._meta.app_label,
model._meta.module_name,
view)

Just my 2 cents.

Germán

On Wednesday, November 13, 2013 9:06:50 AM UTC-3, Florian Apolloner wrote:
>
> Hi Russ,
>
> On Wednesday, November 13, 2013 2:16:13 AM UTC+1, Russell Keith-Magee 
> wrote:
>>
>> The use case was simple -- deploy two instances of admin in a single 
>> project. For example, you might have a truly 'access-all-areas' admin, and 
>> a cut down/modified admin for trusted editors that has specially customised 
>> workflows, etc. Admin has been specifically designed to allow this, and 
>> it's a documented feature [1].
>>
>
> This is something which can be done currently by supplying the name 
> argument to the AdminSite [1] (this changes the instance namespace name for 
> the urlconf). But we also have a lesser known (and not working) feature 
> where you can also modify the app_name itself [2] -- which is causing 
> problems here (application namespace vs instance namespace). I am not sure 
> what app_name provides aside from more complexity :)
>
> Cheers,
> Florian
>
> [1] 
> https://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.AdminSite
>  
> [2] 
> https://github.com/django/django/blob/master/django/contrib/admin/sites.py#L55
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at http://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/5aa1d9c9-363a-4299-98ff-0a0923e8200e%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to