mirror of
https://github.com/Hopiu/django-modeltranslation.git
synced 2026-05-21 02:41:54 +00:00
Added a new forms module with a TranslationModelForm which removes the translation fields (thanks to Dylan Verheul).
This commit is contained in:
parent
11e77b4c31
commit
d9967525a4
1 changed files with 12 additions and 0 deletions
12
modeltranslation/forms.py
Normal file
12
modeltranslation/forms.py
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from django import forms
|
||||
|
||||
from modeltranslation.fields import TranslationField
|
||||
|
||||
|
||||
class TranslationModelForm(forms.ModelForm):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(TranslationModelForm, self).__init__(*args, **kwargs)
|
||||
for f in self._meta.model._meta.fields:
|
||||
if f.name in self.fields and isinstance(f, TranslationField):
|
||||
del self.fields[f.name]
|
||||
Loading…
Reference in a new issue