Hi Florian I used to do that (pass `current_app='other_admin'` to reverse) and it worked fine until I hit a bump road (sorry, can't remember which) where I couldn't reverse to the admin site that I wanted by using `current_app` (it reversed to the "main" one if the URL name existed else raised a NoReverseMatch). And reading the docs again:
AdminSite instances take a single argument to their constructor, their > name, which can be anything you like. This argument becomes the prefix to > the URL names for the purposes of reversing them. This is only necessary if > you are using more than one AdminSite. https://docs.djangoproject.com/en/1.6/ref/contrib/admin/#multiple-admin-sites-in-the-same-urlconf So the name of the "other admin" becomes the prefix to the URL names for the purpose of reversing them. Now I'm more confused. On Thursday, November 14, 2013 7:45:39 AM UTC-3, Florian Apolloner wrote: > > Hi Germán, > > in your case you should be using current_app; then using > reverse('admin:bla') will tell the urlresolver to reverse an admin url bla > for an AdminSite with name == current_app -- this will also work in > templates; which is good since you really don't want to change string > there… When you need to refer to the "other" admin just pass > current_app='other_admin' to reverse. > > Chers, > Florian > > On Thursday, November 14, 2013 1:55:13 AM UTC+1, German Larrain wrote: >> >> 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 [email protected]. To post to this group, send email to [email protected]. 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/0652b37c-75e5-47bd-bd9a-622a9cea86c3%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
