Created
June 28, 2012 09:07
-
-
Save bmihelac/3010093 to your computer and use it in GitHub Desktop.
Refresh django ContentType names
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# changing verbose name of model does not change ContentType name | |
# this script will loop through all ContentType objects and refresh names | |
# optional activate translation | |
from django.utils import translation | |
translation.activate('en') | |
from django.contrib.contenttypes.models import ContentType | |
content_types = ContentType.objects.all() | |
for ct in content_types: | |
model = ct.model_class() | |
if model: | |
ct.name = model._meta.verbose_name | |
ct.save() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
AttributeError: can't set attribute in Django 3