On Apr 6, 5:29 pm, Paweł Roman <romapa...@googlemail.com> wrote:
> Hi all,
>
> Django has this DATETIME_FORMAT setting, which allows to format all
> datetime values, whenever they are displayed. But the problem is this
> is a _global_ setting, so whoever uses the application would see all
> the datetimes formatted exactly the same way. I'd like to allow
> individual users to select their own favorite datetime format. What I
> don't know is which method I should override to be able to manually
> format a datetime field on a model when it is being rendered.
>

Off the top of my head:

I would probably store in the user profile model the user's preferred
format string. Then I'd create a template tag that would format a
given datetime with that setting, e.g.:

{% now_in_user_format user %}

Inside that tag you would get the user's profile (user.get_profile())
and then return a string that is now().strftime(users_format).

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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