question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Django does not create migrations to translate models

See original GitHub issue

Hi there. I need to translate my site and I decided to use modeltranslation to translate the models. But I have a problem, Django does not see the code to translate and does not create migrations.

My code

settings.py

INSTALLED_APPS = [
    'django.contrib.admin',
    
    ...

    'apps.service',
    'modeltranslation',
]

USE_I18N = True

USE_L10N = True

USE_TZ = True

MODELTRANSLATION_DEFAULT_LANGUAGE = 'en'
MODELTRANSLATION_LANGUAGES = ('en', 'uk')
USE_MODELTRANSLATION = True

model.py

class Service(models.Model):
    title = models.CharField("Назва сервісу", max_length=200, unique=True)
    content = models.TextField("Опис", blank=True, null=True)
    short_description = models.CharField("Короткий опис", max_length=250, blank=True, null=True)

translations.py

from .models import Service, Post
from modeltranslation.translator import register, TranslationOptions


@register(Service)
class ServiceTranslationOption(TranslationOptions):
    fields = ('title', 'content', 'short_description')

When creating migrations, nothing happens.

$ ./manage.py makemigrations service
No changes detected in app 'service'

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
last-partizancommented, Jul 27, 2020

Oh, i see. Change translations.py -> translation.py.

0reactions
Korzhakcommented, Jul 27, 2020

I’m stupid. Thank you!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Migrations - Django documentation
Migrations ¶. Migrations are Django's way of propagating changes you make to your models (adding a field, deleting a model, etc.) into your...
Read more >
django - makemigrations doesn't detect changes in model
I tried to migrate the changes, but makemigrations doesn't detect the change. It's just the development version, so I can resync (I don't...
Read more >
Making Django migrations in Python - LogRocket Blog
Your models in app(s): 'rockets' have changes that are not yet reflected in a migration, and so won't be applied. Run 'manage.py makemigrations ......
Read more >
Unable to Make existing fields translatable · Issue #263 - GitHub
I am having troubles with Django-Parler 2.0.1 after I had applied migration to translations to make existing fields translatable, it won't show Product ......
Read more >
Migrating from django-modeltranslation - Read the Docs
Run ./manage.py migrate to apply the generated data migrations. Your models with translated fields should have a populated i18n field after these migrations....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found