It's also possible to inspect `request.META['HTTP_ACCEPT_LANGUAGE']`,
although while building an English/Chinese site recently I found this
somewhat unreliable. In the end I decided to use it as a default so
that at least some of the Chinese visitors will see the content in
Chinese right away; those that don't can click the "中文" link.

    if request.META['HTTP_ACCEPT_LANGUAGE'].lower().startswith('zh'):
        language = 'chinese'
    else:
        language = 'english'

David


On Aug 26, 12:20 am, ringemup <ringe...@gmail.com> wrote:
> Unless most of your users will be on location-enabled mobile devices,
> automatic location detection is usually IP-based, so you'd need to
> find either a database or a service with an API to do lookups.
>
> On Aug 25, 3:37 am, Andy <selforgani...@gmail.com> wrote:
>
>
>
> > I'd like to detect the location of each user and then set the default
> > language and location for him accordingly. The homepage would also be
> > tailored to each location (country and city).
>
> > Can anyone share information on how to do that with Django?

-- 
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