google-code-export / django-modeltranslation

Automatically exported from code.google.com/p/django-modeltranslation
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Allow either default field in admin #80

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Model with a required field. A number of fields are then created by 
modeltranslation and in admin it requires that the default language field is 
used. Would it be possible to make it so it is accepted if at least one of the 
fields are entered?

i.e.

in models.py
name = models.CharField(max_length=255)

In the admin pages this will show up as:

Name-en *required*

Name-es

Preferably an option should allow for either field to fulfil the requirement.

Original issue reported on code.google.com by chriseva...@gmail.com on 5 Jul 2012 at 2:13

GoogleCodeExporter commented 9 years ago
Basically that would require to add a form with a clean method.

In addition, and that is the easier part, all translation fields have to be 
made optional. This can already be achieved by overriding formfield_for_dbfield 
and setting field.required to False, like this:

    def formfield_for_dbfield(self, db_field, **kwargs):
        field = super(TranslationBaseModelAdmin, self).formfield_for_dbfield(
            db_field, **kwargs)
        self.patch_translation_field(db_field, field, **kwargs)
        if hasattr(field, 'required'):
            field.required = False
        return field

As i'm currently working on some bigger admin refactoring i will see if this 
feature can be added in a sensible way.

Original comment by eschler on 6 Jul 2012 at 9:38

GoogleCodeExporter commented 9 years ago
Project moved to Github. All issues have been migrated preserving their id. All 
remaining open issues on GoogleCode are closed. New project url: 
https://github.com/deschler/django-modeltranslation

Original comment by eschler on 22 Oct 2012 at 8:22