Hi Xina, The short answer is "not easily, and not within Django".
Django's DB Routers don't contain any detail about the request, so there's no ability to geolocated the requesting IP for routing purposes. For the record, this is because Django is a general purpose toolkit - there's no guarantee that a request to access the DB has come as a result of a HTTP request - it might come from a standalone script, which won't have an IP address. So - you'll need to look further up the stack to do this sort of routing. My suggestion would be to look at the web server level. The simplest approach would be to deploy multiple "versions" of your app on different subdomains - "asia.example.com, us.example.com, europe.example.com", and rely on users to pick the right domain. Each version would be running exactly the same code - but they would each have a different settings file, pointing to the asia database, us database and so on. A more complex approach would be to use IP-based routing at the web server. NginX has plugins like GeoIP to redirect traffic based on the IP of the requesting user. In this configuration, you'd still have multiple servers, but the NginX server would be directing traffing from the root "example.com" to the right geolocated server. Yours, Russ Magee %-) On Sun, Mar 8, 2015 at 4:06 AM, xina towner <xinatow...@gmail.com> wrote: > Hi, > > is there any possibility that we could select the database to which route > a request of a user depending on the geolocalization of the client? Or the > user country? > > I've check some documentation of the dbrouters, but I am concerned that if > a user travels to another country he is going to be routed to the wrong > database. > > Does anybody have know how to solve this issue? > > > -- > Gràcies, > > Rubén > > -- > 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+unsubscr...@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/CANGESS-w7ctv9AeGkbBymuhLgYAdEZqcDSrkwPCd3Rw8-6Rkjw%40mail.gmail.com > <https://groups.google.com/d/msgid/django-users/CANGESS-w7ctv9AeGkbBymuhLgYAdEZqcDSrkwPCd3Rw8-6Rkjw%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- 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+unsubscr...@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/CAJxq8490NDW4WLjEQ%3DLn_8yh1MY-Z-hKHATkR6aS6ZzickiqHA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.