1

I would like to copy a translated field from a model instance var_product of class Product to another model instance var_ordered_product of class OrderedProduct.

model.py

class Product(OwnedModel):
    name = models.CharField(max_length=255)

class OrderedProduct(OwnedModel):
    name = models.CharField(max_length=255)

translation.py

@register(Product) 
class ProductTranslationOptions(TranslationOptions):
    fields = ('name', )

@register(OrderedProduct) 
class OrderedProductTranslationOptions(TranslationOptions):
    fields = ('name', )

In my code

var_ordered_product.name = var_product.name

should copy the name field including all field translations.

Question: Is copying/cloning possible, without copying the language fields individually, like

var_ordered_product.name_en = var_product.name_en
var_ordered_product.name_fr = var_product.name_fr
Bearny
  • 11
  • 2

0 Answers0