Hello Phil,

Thanks for the answer. I already know about how to separate settings
between development and production; but that's not what I'm trying to
do and I couldn't find how to adapt for separating settings between
development and test-time. That is, I haven't found any way to make './
manage.py test' pick a different settings file or be able to customize
settings. Do you know how?
Now, regarding the reason I want to customize MEDIA_ROOT; it's to be
able to locate the files referred to by FileFields. Whether I do it
modifying it at run time or with a settings files I don't care because
it's just for a test, it's not for production. As long as it works I'm
ok.

Thanks.

On Apr 22, 4:39 pm, Phil Mocek <pmocek-list-django-us...@mocek.org>
wrote:
> 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-developm...>
>
> "Multiple django configurations for development and production ..."
> <http://www.bearfruit.org/blog/2008/05/28/multiple-django-configuratio...>
>
> "Ninjacipher » Blog Archive » django alternate development settings ..."
> <http://www.ninjacipher.com/2008/03/02/django-alternate-development-se...>
>
> 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/1e8ac12...>
>
> 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-settin...>
>
> 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 django-users@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