mirror of
https://github.com/Hopiu/django-modeltranslation.git
synced 2026-05-04 03:24:52 +00:00
Added docs on registration using the decorator.
This commit is contained in:
parent
80d804b03e
commit
6b5d9355cd
1 changed files with 12 additions and 0 deletions
|
|
@ -50,6 +50,18 @@ only imported. The ``NewsTranslationOptions`` derives from
|
|||
``TranslationOptions`` and provides the ``fields`` attribute. Finally the model
|
||||
and its translation options are registered at the ``translator`` object.
|
||||
|
||||
If you prefer, ``register`` is also available as a decorator, much like the
|
||||
one Django introduced for its admin in version 1.7. Usage is similar to the
|
||||
standard ``register``, just provide arguments as you normally would, except
|
||||
the options class which will be the decorated one::
|
||||
|
||||
from modeltranslation.translator import register, TranslationOptions
|
||||
from news.models import News
|
||||
|
||||
@register(News)
|
||||
class NewsTranslationOptions(TranslationOptions):
|
||||
fields = ('title', 'text',)
|
||||
|
||||
At this point you are mostly done and the model classes registered for
|
||||
translation will have been added some auto-magical fields. The next section
|
||||
explains how things are working under the hood.
|
||||
|
|
|
|||
Loading…
Reference in a new issue