Hi Martin- Yes, that is what that code would do... I guess I forgot about how context processors work. :-P
I think most people do this type of thing with a round-robin server setup. If you wanted to do it django-side, you'd probably need to do a template tag. Note the callable... -Steve random_media.py ----------------------------- from django import template from random import choice register = template.Library() def media_url(): media_urls = ['site1.example.com', 'site2.example.com', 'site3.example.com'] return choice(media_urls) register.simple_tag(media_url) in some template ------------------ {% load random_media %} {% media_url %} ==================================== Steven L Smith, Web Developer Department of Information Technology Services Nazareth College of Rochester 585-389-2085 | ssmit...@naz.edu http://www.naz.edu/pub/~ssmith46 ==================================== ----- Original Message ----- From: "Martin Siniawski" <msi...@gmail.com> To: "Django users" <django-users@googlegroups.com> Sent: Tuesday, June 8, 2010 8:32:53 AM GMT -05:00 US/Canada Eastern Subject: Re: Using array of URLs for MEDIA_URL Steve, Thanks for the answer. If I understand correctly your idea and code, each template would have only one value for the MEDIA_URL (randomly chosen from the array), right? What I was looking for was a way of distributing the value of the MEDIA_URL uniformly along the values of an array, in each template. So in a certain template the MEDIA_URL would have more than one value. Maybe if I set it as a callable (with the logic that choses the values inside it) that would work. I cannot quite understand why there isn't anymore people running into this issue. Best and thanks again for the answer, Martin On Jun 7, 10:46 am, Steven L Smith <ssmit...@naz.edu> wrote: > Hi Martin- > > I don't know what the "official" answer would be, but you could write your own > context processor that had something like: > > from random import choice > MEDIA_URLS = 'static1.site.com', 'static2.site.com', 'static3.site.com' ] > def media(request): > return {'MEDIA_URL': choice(MEDIA_URLS)} > > Then, in settings.py, include your custom context processor instead of the one > built-in to to Django. > > -Steve > > ==================================== > Steven L Smith, Web Developer > Department of Information Technology Services > Nazareth College of Rochester > 585-389-2085 | ssmit...@naz.eduhttp://www.naz.edu/pub/~ssmith46 > ==================================== -- 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. -- 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.