How to add Middleware to my code. I cant import  from django.utils
import timezone
please guide me. How to import timezone. I already installed pytz. any
one help me. any clues.

Here's an example that stores the current timezone in the session. (It
skips error handling entirely for the sake of simplicity.)

Add the following middleware to MIDDLEWARE_CLASSES:

from django.utils import timezone

class TimezoneMiddleware(object):
    def process_request(self, request):
        tz = request.session.get('django_timezone')
        if tz:
            timezone.activate(tz)


https://docs.djangoproject.com/en/dev/topics/i18n/timezones/#selecting-the-current-time-zone


-Ganesh

Did I learn something today? If not, I wasted it.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to