Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python

Luke Fisher
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Luke Fisher
Python Web Development Techdegree Graduate 17,183 Points

Anyone get this error? How should I fix it? I am currently on Project 9 for the Python Techdegree

django.core.exceptions.ImproperlyConfigured: Requested setting DEFAULT_INDEX_TABLESPACE, but settings are not config ured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before acc essing settings.

This error started popping up as soon as I ran the statement coverage run tests.py. Any ideas or clues?

1 Answer

Alex Koumparos
seal-mask
.a{fill-rule:evenodd;}techdegree
Alex Koumparos
Python Development Techdegree Student 36,887 Points

Hi Luke,

It looks like Django isn't being loaded (which means Django's settings aren't available to your test scripts). What happens if instead of the command you are using, you try:

coverage run manage.py test

When you try to run your test scripts directly, they are not able to access Django's settings. If you load manage.py with the test argument, it will execute any tests it can find with Django running.

Thus instead of telling coverage to run your test scripts directly, we are telling coverage to run the tests through Django.

Hope that helps

Alex