Guest User

Untitled

a guest
Nov 19th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. # changing verbose name of model does not change ContentType name
  2. # this script will loop through all ContentType objects and refresh names
  3.  
  4. # optional activate translation
  5. from django.utils import translation
  6. translation.activate('en')
  7.  
  8. from django.contrib.contenttypes.models import ContentType
  9. content_types = ContentType.objects.all()
  10.  
  11. for ct in content_types:
  12. model = ct.model_class()
  13. if model:
  14. ct.name = model._meta.verbose_name
  15. ct.save()
Add Comment
Please, Sign In to add comment