On Tue, Apr 21, 2009 at 11:29:38PM -0700, J. Pablo Fern?ndez wrote: > I need to change MEDIA_ROOT while running tests, so that the files > pointed to in fixtures in ImageFields can be found. [...] Any ideas > how can I achieve this?
I assume you've already searched the Web with terms like "django multiple settings," "django alternative settings," and "django development settings." Among the top results returned by Google are: "Django settings files for development and production - Martin Jansen" <http://martinjansen.com/2008/10/20/django-settings-files-for-development-and-production/> "Multiple django configurations for development and production ..." <http://www.bearfruit.org/blog/2008/05/28/multiple-django-configurations-for-development-and-production> "Ninjacipher » Blog Archive » django alternate development settings ..." <http://www.ninjacipher.com/2008/03/02/django-alternate-development-settings-file/> So that subscribers to this list can better assist you, please tell us what you learned from the information that is easily found on the Web, and what you have already tried based on that information. Also, as you're probably a considerate person who respects other people's time, it should be safe to assume that before you asked your question on this list, you searched the list archives to determine whether the topic has previously been discussed (because you'd be wasting your time and that of other subscribers if you brought it up again for any reason other than extending the discussion or requesting clarification). When I search <http://groups.google.com/group/django-users/> for "testing settings", the *second* result is: "media directory for testing" <http://groups.google.com/group/django-users/browse_frm/thread/1e8ac12af67c2eb1/d08cf155ab2a025b?lnk=gst&q=testing+settings#d08cf155ab2a025b> How did the answers people already provided to Faheem Mitha's 2007 question work out for you? > I've tried settings.MEDIA_ROOT = "blah" in the test method and in the > setUp method but still it tries to find the file in the wrong > location. Since you're having difficulty making Django settings work the way you want, I assume you've thoroughly read the related documentation: <http://docs.djangoproject.com/en/1.0/topics/settings/> In section "Altering settings at runtime" of that document: <http://docs.djangoproject.com/en/1.0/topics/settings/#altering-settings-at-runtime> is written: >> You shouldn't alter settings in your applications at runtime. For >> example, don't do this in a view: >> >> from django.conf import settings >> >> settings.DEBUG = True # Don't do this! >> >> The only place you should assign to settings is in a settings file. What was your rationale for trying to do *precisely* what the Django authors told you not to do? See also: <http://www.catb.org/~esr/faqs/smart-questions.html>, particularly this section: <http://www.catb.org/~esr/faqs/smart-questions.html#rtfm> -- Phil Mocek --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---

