On Monday, 7 December 2015 23:40:51 UTC, knbk wrote: > Namespaces are a mess, and have been for a while. 1.9 cleans this up a > bit. Some advice for 1.8 to stay in line with the 1.9 changes: > > - Always define an application namespace when using an instance > namespace. > - An app shouldn't depend on the project's url configuration, so > always use the application namespace in the view name, i.e. > reverse('polls:view'), not reverse('author-polls:view'). > - A project that uses an app may point to a specific instance > namespace of that app when necessary, i.e. on the front page with links to > both author-polls and publisher-polls. > - The currently active instance namespace is available as > request.resolver_match.namespace. > - You can set request.current_app = request.resolver_match.namespace > before > rendering templates, and the {% url %} template tag will use the > current namespace for urls in the same application namespace. > > It seems a bit weird that that's not automatic.
> > - You can explicitly pass the current namespace to current_app in > reverse() to do the same. > > That still leaves the question of what Model.get_absolute_url() should do, given that it has no way to get the current app that I can see. Thank you for your very helpful comments though. -- 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+unsubscr...@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/47d50462-b751-4203-a87f-5e9ad7fbbb50%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.