Why Django modeltranslation too many feilds

0 votes

I want to translate the name field in the django application (1.11) using django-modeltranslation. I want to translate to en and fr, but in the admin panel I get 3 fields instead of two: name, name_en, name_fr.

models.py

class Country(models.Model):
    name = models.CharField(max_length=100)
    code = models.SlugField(max_length=20, default='')

    def __str__(self):
        return self.name

admin.py

class CountryAdmin(admin.ModelAdmin):
    list_display = ('name_en',)

translation.py

from events.models import Country

class CountryTranslationOptions(TranslationOptions):
    fields = ('name',)
translator.register(Country, CountryTranslationOptions)

Oct 1, 2018 in Python by bug_seeker
• 15,510 points
312 views

1 answer to this question.

0 votes
answered Oct 1, 2018 by Priyaj
• 57,700 points

Related Questions In Python

0 votes
1 answer
0 votes
1 answer

ValueError: too many values to unpack (expected 3)

Hello @Alisha , Do print(func(x)) and find out what's ...READ MORE

answered Aug 12 in Python by Niroj
• 76,540 points
1,138 views
0 votes
1 answer

Python join: why is it string.join(list) instead of list.join(string)?

950down voteaccepted It's because any iterable can be ...READ MORE

answered May 15, 2018 in Python by aryya
• 7,400 points
157 views
0 votes
1 answer

Python join: why is it string.join(list) instead of list.join(string)?

This is because join is a "string" ...READ MORE

answered Jul 30, 2018 in Python by Priyaj
• 57,700 points
185 views
0 votes
1 answer

how to download and install Django rest framework?

To install Django, you can simply open ...READ MORE

answered Apr 24, 2018 in Python by Christine
• 15,810 points
513 views
0 votes
1 answer
0 votes
1 answer

Host not allowed

Go to your project directory cd project cd project ALLOWED_HOSTS ...READ MORE

answered Aug 9, 2018 in AWS by Priyaj
• 57,700 points
657 views
0 votes
1 answer

Python exit commands - why so many and when should each be used?

Let me give some information on them: quit ...READ MORE

answered Aug 27, 2018 in Python by Priyaj
• 57,700 points
46,296 views
+1 vote
1 answer

Why is openpyxl is required for loading excel format files?

Well, it sounds like openpyxl is not ...READ MORE

answered Aug 8, 2018 in Python by Priyaj
• 57,700 points
245 views