Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7091489
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T08:11:30+00:00 2026-05-28T08:11:30+00:00

I am developing an multilingual application using Django. One part is to select the

  • 0

I am developing an multilingual application using Django.
One part is to select the type of something using the ContentType API.

As describe in the doc, the ContentType object name is extracted from the verbose_name.

In my case the verbose_name is translated using xgettext_lazy but as it is copyied in the database during the syncdb, there is no translation for ContentType, the verbose_name is not translated.

I would like to be able to change the way the foreign key is displayed in a form.

Do you have any idea of how I can do that ?

Cheers,

Natim

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T08:11:31+00:00Added an answer on May 28, 2026 at 8:11 am

    Finally here is the solution I found :

    def content_type_choices(**kwargs):
        content_types = []
        for content_type in ContentType.objects.filter(**kwargs):
            content_types.append((content_type.pk, content_type.model_class()._meta.verbose_name))
    
        return content_types
    
    LIMIT_CHOICES_TO = {'model__startswith': 'pageapp_'}
    
    class PageWAForm(forms.ModelForm):
        app_page_type = forms.ModelChoiceField(queryset=ContentType.objects.filter(**LIMIT_CHOICES_TO), 
                                               empty_label=None)
    
        def __init__(self, *args, **kwargs):
            super(PageWAForm, self).__init__(*args, **kwargs)
            self.fields['app_page_type'].choices = content_type_choices(**LIMIT_CHOICES_TO)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We are developing a multilingual Winforms application using visual studio 2008. I am trying
Iam developing one application.In that i use the google api for getting the location
Iam developing one application.In that i use the google api for getting the location
I am developing a multilingual web application that has a nice looking UI. I
Developing a multilingual application in VB.Net 2008, Im able to add resources to forms
I am developing a Ruby on Rails application with multilingual support. Now I have
I'm trying to implement multilingual indexes for the web application I'm developing. At the
I'm developing a multilingual PHP web application, and I've got long(-ish) texts that I
I'm developing a multilingual web site and the localization is done mostly by using
I'm developing a web application using ASP.NET MVC (I'm new to the framework and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.