Wednesday, February 5, 2014

Re: Model field's verbose_name from database?

On Wed, Feb 5, 2014 at 5:47 PM, Jon Dufresne <jon.dufresne@gmail.com> wrote:
>> Why not use dictionary to Map user-level names to database-fields
>
> I'm not sure I fully follow what you're suggesting. But it sounds like
> you're suggesting I move the configuration of field name out of the
> database and into a Python file using a dictionary to map actual
> fields to preferred field names. Is this correct?
>
> I can't do this because:
>
> * I do not know the user's preference ahead of time
> * Their preference could change as time goes on
> * It is unreasonable (in my case) to expect my users to modify python files
> * These preferences could be different across different installations
>
> For this reason, these fields are configured as a sort of "user
> setting". The user is in complete control. But, once they are set,
> they should be used everywhere.

Do the names of the fields differ for different installation instance,
or do they differ for different users on the same installation?

If the former, I would do it with translations. Combined with
something like django-rosetta, you can easily knock up an interface to
allow super-users to set the translation for "First name" to whatever
they want by translating the "en" language (or indeed, any language).
If your site is multi-lingual already, this should be quite easy (and
frankly, if its not, its also very easy to configure). verbose_name
will happily accept a lazy translation as a value, converting it on
display to the "language" specified .

If the latter, then I don't think you can hammer this in to the
verbose_name mechanism without becoming very inventive - perhaps still
with translations, activating a different .mo file per-user?

Cheers

Tom

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAFHbX1LkRG1_0oDepzJO%2B_LaTeK%2BCyLN3KnwSh1tQ1pj-ZO22Q%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment