Skip to content
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

When using i18n_patterns, every path is prefixed with the current language so it can have several versions #34

Open
mandx opened this issue Aug 26, 2012 · 1 comment

Comments

@mandx
Copy link

mandx commented Aug 26, 2012

If in your Django has several languages configured, and your root URLConf is using the new i18n_patterns, then every path under that urlpatterns setup can have two or more versions. Currently, DjangoSEO assumes that every get_absolute_url call will return an unique URL, when that's not the case for multilingual projects.

For instance, when i18n_patterns is active, a call to get_absolute_url can return /en/objects/myobject_slug/ or /de/objects/myobject_slug/, depending on the current request language.

The result of every call to get_absolute_url (or when using request.path) should be unprefixed from the current language, before using it as "key" to save the metadata instance.

@danigosa
Copy link

The workaround is using the views Backend using named views.

Add your seo model:

Meta:
use_i18n = True
seo_views = ("your_view_name",)

Then add two views in the admin, each with a different language from the dropdown.

In your view, add a context parameter like that:

{"view_name": "your_view_name"}

In the template use the following:

{% get_metada for view_name in LANGUAGE_CODE %}

Eh voilà.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants