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.

NotRegistered: The model "Permission" is not registered for translation

See original GitHub issue

After spending ~8hrs of time figuring out the problem, and after a nonsensical pull request, I can report I’ve found an issue:

I have a translated InheritedPermission model inherited from django’s Permission, on which I use some translated fields.

When accessing the Permission with has_perm from the user angle, modeltranslation explodes. Probable cause is the Permission.objects manager gets replaced after expiring the relations cache, which can happen on various occasions (at my project it happens at initialization time).

I’ve created a test in my fork that reproduces the bug: see #466 and the latest failing commit.

@deschler, can we get a quick fix and a release? modeltranslation not being released for Django 2.x is the biggest blocker for me from changing to Django 2.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:7
  • Comments:14 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
last-partizancommented, Feb 17, 2019

Looks like i fixed issue by making patched managers local to the translated model.

Will release beta3 soon.

0reactions
last-partizancommented, Feb 18, 2019

@felixxm take a look anyway 😃 my fix is working, and did not break any tests, but maybe you have better idea.

Read more comments on GitHub >

github_iconTop Results From Across the Web

"django.contrib.admin.sites.NotRegistered: The model User is ...
I tried to unregistered default user model and register custom. # -*- coding: utf-8 -*- from django.contrib import admin from django.http import ...
Read more >
The model "HomePage" is not registered for translation
modeltranslation.translator.DescendantRegistered: Model "Page" cannot be registered after its subclass "Form". I apply suggested solution.
Read more >
Registering Models for Translation - django-modeltranslation
For each model to translate, a translation option class containing the fields to translate is registered with a special object called the translator...
Read more >
Source code for django.contrib.admin.sites
_registry: raise NotRegistered('The model %s is not registered' % model. ... given HttpRequest has permission to view *at least one* page in the...
Read more >
django.contrib.admin.sites register Example Code
The register function is used to add models to the Django admin so that data ... from django.contrib.sites.models import Site from django.utils.translation ......
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