I'm writing some tests and I need to create some objects but I get this error when I try to create some object outside a Django View
cat = Category.objects.create(catalog=c, name="Category one")
Returns
TypeError: 'name_es' is an invalid keyword argument for this function
This fails with modeltranslation 0.6.1 but works with 0.3.2
name
is a field translated with modeltranslation.
From the docs:
The unittests use the django.utils.translation.trans_real functions to activate and deactive a specific language outside a view function.
I've tried this:
trans_real.activate('es')
cat = Category.objects.create(catalog=c, name="Category one")
And I get the same error :(
Anyone knows a better way for testing modeltranslation based models in Django?
EDITED
More things tried so far:
cat = Category.objects.create(**{'catalog':c, 'name': 'Category one'})
TypeError: 'name_es' is an invalid keyword argument for this function