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

  • SEARCH
  • Home
  • 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 6040427
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T06:30:45+00:00 2026-05-23T06:30:45+00:00

We are now using Django to develop a multilingual website. We have different language

  • 0

We are now using Django to develop a multilingual website. We have different language version for content on our website. For example, for a post, we have English and Spanish version.
Currently we are using this model:

class Post(models.Model):
    user
    title
    detail
    count_follower
    ...
    orginal_language
    date


class PostEspanish(models.Model):
    post = models.ForeignKey(Post)
    title
    detail

So we use Post for all English content and PostEspanish for Spanish content.
If someone writes a post in English we just put it in Post model, and we put translated post in PostEspanish model. And if someone writes a post in Spanish, we first create a Post instance, then create a PostEspanish instance and put content in PostEspanish, and if someone translate this Spanish post, we put translated post in its referring Post.

Storing different language content on different model is because the search guy want it this way. He says it is good for the search.

To make it clearer, for instance, some user writes a post, we will do the following:

if language == 'English':
    post = Post.objects.create(..., orginal_language='english')
else:
    post = Post.objects.create(..., original_language='espanish')
    PostEspanish.objects.create(post=post, ...)

and translates:

post = Post.objects.get(id=id)
if post.orginal_language == 'english':
    post = post.postespanish
    #update post
    post.save()
else:
    #update post
    post.save()

Today someone said this model design is really poor. He said the current model is not well object oriented. Here is the way they do it:

class Post(models.Model):
    user
    count_follower
    ...
    orginal_language
    date

class PostContentEnglish(models.Model):
    post = models.ForeignKey(Post)
    title
    detail

class PostContentEspanish(models.Model):
    post = models.ForeignKey(Post)
    title
    detail

So the code will be like this:

if language == 'English':
    post = Post.objects.create(..., orginal_language='english')
    PostContentEnglish.objects.create(post=post,...)
else:
    post = Post.objects.create(..., orginal_language='espanish')
    PostContentEspanish.objects.create(post=post,...)

But most of us thought there is no difference between these two approaches. And his model design will generate one more table which is really bad.

So which one do you think is better?

  • 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-23T06:30:46+00:00Added an answer on May 23, 2026 at 6:30 am

    Typically, languages are stored like this (pseudo-code):

    posts (
      id       serial pkey,
      pubdate  datetime
    )
    
    posts_lang (
      id       int fkey posts (id),
      lang     char(2),
      title    varchar,
      content  text,
      pkey (id, lang)
    )
    

    An alternative approach I’ve seen a few times, is this:

    posts (
      id       serial pkey,
      parent   int fkey posts (id),
      lang     char(2),
      pubdate  datetime
      title    varchar,
      content  text
    )
    

    Its benefit is that it allows to deal with locale-specific attributes (english tags/meta vs spanish tags/meta, for instance). But it quickly turns into a nightmare of tree handling. So not recommended.

    And, of course, there’s the one you’re using, with the default language directly in the table:

    posts (
      id       serial pkey,
      pubdate  datetime
      title    varchar,
      content  text,
    )
    
    posts_lang (
      id       int fkey posts (id),
      lang     char(2),
      title    varchar,
      content  text,
      pkey (id, lang)
    )
    

    I can see the rational for wanting the default language straight into the table. But in my experience it introduces code duplication — i.e. you’re constantly doing things two ways — and thus bugs/quirks. So can’t really recommended either.

    My preferred alternative is none of the above — and using a different schema (or DB, or table prefix) for each language:

    en.posts (
      id       serial pkey,
      pubdate  datetime
      title    varchar,
      content  text
    )
    
    es.posts (
      id       serial pkey,
      pubdate  datetime
      title    varchar,
      content  text
    )
    

    The reason I prefer it is that it’s frequent for a site to have untranslated pages and such, or pages that exist on one site but not the other. And more often than not your content should not be identical from a country to the next anyway — you do not communicate to your audience the same way.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am used to using Django for some time now. Now I have to
I have been using django-appengine and am now trying a project with django-nonrel. Before
I have a xml which is max 3 levels deep. Now by using C#
I am trying develop a basic referrer system to my Django website, system will
I'm using django-compress to shrink my JavaScript files. However, I am now having trouble
I've been using django-mptt in my project for a while now, it's fabulous. Recently,
I am kinda stuck, I've been using Django for a while now, but I
we are using django to develop a customer-management application, and we need to set
I have a strong background in PHP / ZEND and I'm now using learning
I created a pretty basic Django project using django-admin and I'm now running into

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.