I have written and tested this short piece of code:
---------------------------------------------------------------
from django.db.models import *
from django.utils.translation import ugettext as _

def verbose_names(model):
    cvname = _(model._meta.verbose_name)    # class verbose name
    for field in model._meta.fields:
        fvname = field.verbose_name    # field verbose name
        field.verbose_name = _(cvname + "-" + fvname)
        field.help_text = _(cvname + "-" + fvname + "-help")
    model._meta.verbose_name = _(cvname)
    model._meta.verbose_name_plural = _
(model._meta.verbose_name_plural)

class SomeModel(Model):
    someAttribute = DateTimeField()
verbose_names(SomeModel)

class SomeModel2(Model):
    someAttribute = DateTimeField()
verbose_names(SomeModel2)
----------------------
My question are:
1. Seems to be it works but is there some more elegant solution? The
requirement is create an internalization dictionary automaticaly
2. How can I follow the DRY principle? To eliminate the "verbose_names
(SomeModel)" for all models. How can I write a verbose_names function
for the whole project?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to