New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
reverse and namespaced urls #1669
Comments
are you using the latest release (2.3.5) or the latest develop version from github? in 2.3.5: namespaced urls don't work |
i'm using the latest release. can you explain the part about 'adding apphook multiple times"? i currently have 3 hooks. |
This refers to using the same apphook multiple times in different locations. The problem is here, that all the views need to be aware of this and set the application namespace correctly. This is in order that url reversal (in templates and views) stay within the same instance of the app. Without namespacing it still works, but all the reverse urls will point to whatever urls where loaded first (or last, I'm not sure). If you are using 3 different apphooks, or the same one but each in different languages that problem does not apply. However, to get back to what I think your question was, django-cms 2.3.5 does not support connecting any urls that use namespaces with an apphook. There is a bug that eats the namespace and thus the reversing does not work anymore. sorry :-( |
well, here's the thing...when i remove the xxx from 'xxx:path', it appears to work, but then, there's no path 'info' as defined in the django.core.urlresolvers.py. so, when i click on a link, nothing happens because cms(?) doesn't know are there plans on fixing the use of reverse, what about writing some clever middleware? |
plans... yes :-) |
would you mind clarifying this: "This refers to using the same apphook multiple times in different locations"? thanks for your prompt response!!! |
example: There is a blog app. Now you want to use it on the same site in multiple locations. Each of the two blogs would have its own instance namespace but they share the same app namespace. Lets assume the app namespace is In regular django the urls would be defined like this: urlpatterns = patterns('',
url(r'^my/blog1/', include('blog.urls', app_name='blog', namespace='blog1'),
url(r'^my/blog2/', include('blog.urls', app_name='blog', namespace='blog2'),
) But with AppHooks the namespace would need to be defined in the database and passed in with the cms generated url resolver.
I guess a view that supports namesspaces could look something like this (untested!): from django.core.urlresolvers import resolve
class MyView(View):
namespace = None
def dispatch(self, request, *args, **kwargs):
self.namespace = resolve(request.path).namespace
return super(MyView, self).dispatch(request, *args, **kwargs)
def get_success_url(self):
return reverse('blog:archive', current_app=self.namespace)
def render_to_response(self, context, **response_kwargs):
response_kwargs['current_app'] = self.namespace
return super(MyView, self).render_to_response(self, context, **response_kwargs) Sorry for going off on a tangent here. I hope I'm at least remotely talking about what you wanted to know. ;-) Actually I think it's pretty clear how to solve it now. Somebody (possibly me) just has to find the time to implement it. |
your 'tangent' help make a few things clear. thanks you!!! |
the code you have there mimics my thoughts. the problem is, i would have to rewrite all of the views of the 3rd party app to make it work.... something i'm trying to avoid. 'in develop: I think this is fixed (....' so, basically, i could use the develop version of cms to solve my reverse('xxxx:yyyy') problem? i'm not so worried about multiple instances because there's only one cms app on one website. i'm merely trying to embed the 3rd party |
this is fixed in develop |
hello,
is there a fix for the reverse function? i'm using the latest cms, without any need for i18n
i'm trying to app_hook a 3rd party app that does not use 'urls.py'. so, i used the 3rdparty app's 'get_urls' function and passed that to the app_hook's 'urls' attr., and all is fine as i can see the urls. however, i can't seem to get the reverse to work with 'namespaced urls' in either the template or the code!
thanks in advance
The text was updated successfully, but these errors were encountered: