How to use modeltranslation?

45 views
Skip to first unread message

Josh Karamuth

unread,
Oct 23, 2020, 8:11:23 AM10/23/20
to django-oscar

I'm trying to translate products and categories using modeltranslation but I can't figure out how to set it up.

I forked the catalogue app and created translation.py inside the ecommerce (directory to hold my forks) directory with the following contents:


from modeltranslation.translator import translator, TranslationOptions

from oscar.apps.catalogue.abstract_models import AbstractProduct


class AbstractProductTranslationOptions(TranslationOptions):
fields = ("title", "slug", "description")




translator.register(AbstractProduct, AbstractProductTranslationOptions)

I then add ecommerce.catalogue.apps.CatalogueConfig to INSTALLED_APPS and remove oscar.apps.catalogue.apps.CatalogueConfig

But when I run migrations, nothing happens.

Does anyone know what I'm doing wrong?

Josh Karamuth

unread,
Oct 23, 2020, 8:23:17 AM10/23/20
to django-oscar
Ok I figured it out. I needed to import Product from oscar.apps.catalogue.models instead of AbstractProduct

Farid Musa

unread,
Feb 25, 2021, 7:41:08 AMFeb 25
to django-oscar
Hi!,
Did you handle the translatable fields on the dashboard? The "modeltranslation" package integrates to django-admin seamlessly. Is there a way to do something similar with the django-oscar dashboard?
Thank you in advance!

Josh Karamuth

unread,
Feb 25, 2021, 10:52:59 AMFeb 25
to django...@googlegroups.com
You have to modify dashboard templates to add translated fields

--
https://github.com/django-oscar/django-oscar
http://django-oscar.readthedocs.org/en/latest/
---
You received this message because you are subscribed to a topic in the Google Groups "django-oscar" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/django-oscar/IoChlRzAcbo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to django-oscar...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/django-oscar/8354fe38-8063-41a7-b04f-ee6e9ef80a40n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages