Hello, I discovered
django-modeltranslation and reading the docs I see it's what I need for my project, so I implemented it, but when I'm going to save a model I have, I got an error message:
'name_es' is an invalid keyword argument for this function
Here's my model:
class Event(models.Model):
"""
Event model
"""
name = models.CharField(
max_length=140, verbose_name=_('Event name'))
description = models.CharField(
max_length=200, verbose_name=_('Description'), null=True, blank=True)
organization = models.ForeignKey(Organization)
when I want to create an object, I got that error, example:
In[4]: from apps.event.models import Event
In[5]: e = Event.objects.create(name='evento uno', organization_id='1')
Traceback (most recent call last):
File "/home/anakin/virtenvs/cunuc/local/lib/python2.7/site-packages/IPython/core/interactiveshell.py", line 2883, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-6-ebf1e3e61d3f>", line 1, in <module>
e = Event.objects.create(name='evento uno', organization_id='1')
File "/home/anakin/virtenvs/cunuc/local/lib/python2.7/site-packages/django/db/models/manager.py", line 157, in create
return self.get_queryset().create(**kwargs)
File "/home/anakin/virtenvs/cunuc/local/lib/python2.7/site-packages/modeltranslation/manager.py", line 259, in create
return super(MultilingualQuerySet, self).create(**kwargs)
File "/home/anakin/virtenvs/cunuc/local/lib/python2.7/site-packages/django/db/models/query.py", line 322, in create
obj.save(force_insert=True, using=self.db)
File "/home/anakin/virtenvs/cunuc/local/lib/python2.7/site-packages/django/db/models/base.py", line 545, in save
force_update=force_update, update_fields=update_fields)
File "/home/anakin/virtenvs/cunuc/local/lib/python2.7/site-packages/django/db/models/base.py", line 582, in save_base
update_fields=update_fields, raw=raw, using=using)
File "/home/anakin/virtenvs/cunuc/local/lib/python2.7/site-packages/django/dispatch/dispatcher.py", line 185, in send
response = receiver(signal=self, sender=sender, **named)
File "/home/anakin/virtenvs/cunuc/local/lib/python2.7/site-packages/audit_log/models/managers.py", line 78, in post_save
self.create_log_entry(instance, created and 'I' or 'U')
File "/home/anakin/virtenvs/cunuc/local/lib/python2.7/site-packages/audit_log/models/managers.py", line 71, in create_log_entry
manager.create(action_type = action_type, **attrs)
File "/home/anakin/virtenvs/cunuc/local/lib/python2.7/site-packages/django/db/models/manager.py", line 157, in create
return self.get_queryset().create(**kwargs)
File "/home/anakin/virtenvs/cunuc/local/lib/python2.7/site-packages/django/db/models/query.py", line 320, in create
obj = self.model(**kwargs)
File "/home/anakin/virtenvs/cunuc/local/lib/python2.7/site-packages/django/db/models/base.py", line 417, in __init__
raise TypeError("'%s' is an invalid keyword argument for this function" % list(kwargs)[0])
TypeError: 'name_es' is an invalid keyword argument for this function
I have 'modeltranslation' in my INSTALLED_APPS and this in my settings:
gettext = lambda s: s
LANGUAGES = (
('es', gettext('Spanish')),
('en', gettext('English')),
)
MODELTRANSLATION_DEFAULT_LANGUAGE = 'es'
MODELTRANSLATION_FALLBACK_LANGUAGES = ('es', 'en')
I have migrate my models, so I can see the fields in my DB, even I can see the data saved from the previous command and previous POST requests to the views where I save data, if I make a SELECT query on my Event table on PostgreSQL I can see the 'evento uno' created previously from running the last command and other data, so I don't know what's going wrong neither how to fix it.
I tried using .populate(True) and the same error is raised.
packages:
Django==1.6.5
django-modeltranslation==0.8b1
South==0.1