Closed svandeneertwegh closed 1 year ago
After looking into the template tag implementation of static_alias
I see that an alias is only automatically created for the default language of a site independent of the language the alias is used in. I'd assume that it should be created for any language of the site, at least for the language the template tag is used.
@Aiky30 Is this a bug or a feature? What would be the argument against automatically creating aliases for all static_alias
used latest when they are viewed?
I'm currently experiencing issues with the fix for this issue
Not entire sure what the chain of event is, however, I have the following:
en
language code installed as the only supported language in Django and the only language defined in CMS_LANGUAGES. It's also the default site languageThe code you've modified in the templatetag:
` if hasattr(request, "toolbar"):
language = getattr(request.toolbar.get_object(), "language", None)
if language not in get_language_list(current_site):
language = None
else:
language = get_language_from_request(request)`
...appears to now produce language as None on my setup, whereas the previous code using the default site language worked fine
...then in the AliasContent creating code below:
alias_content = AliasContent.objects.create( alias=alias, name=static_code, language=language, )
...you'll get a 500 error since language cannot be null according to the model/table definition
I'd suggest maybe adding the old default site language check back in if language is None after your new language getting code, just to be defensive?
@andrewhayes1979 Thanks for pointing this out and all the context! The fix in #169 uses get_language_from_request
from cms.utils
which falls back to the site's default language.
My languages are 'nl' (primary) and 'en'. When click at aliases in the site dropdown from the cms_toolbar, i auto create a 'footer' alias for that language (nl) because LANGUAGE_CODE='nl'. Ik can edit en publish and such with thie alias editor.
Point is, when i switch to /en/pages i also click on 'aliases...' but it says no aliases registered.
Python 3.10 Django==3.2 Django-cms==4.1..0rc1