In pycharm can I run every file for django?
<p>I'm new to Django. My localhost site is running fine. Since I am using pycharm it is easy to run any file. I decided to run each file in my django project, and came across several errors, such as this one in my views.py:</p>

<pre><code>django.core.exceptions.ImproperlyConfigured: Requested setting DEFAULT_INDEX_TABLESPACE, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.
</code></pre>

<p>Even though the site is running, what seems like properly, I'm seeing this message. What is causing this, and is it typical?</p>

<p><strong>You can run</strong> any individual <strong>python file</strong> in a Django Project with Django, but keep in mind that the settings for Django must be supplied. This is not a good practise to run individual file with Django but for debugging purposes you may use it (<em>for example. to test a parser that you wrote with database access</em>),</p>

<p>You have to configure the Django settings before you can do anything with Django on a single file.</p>

<pre><code>from django.conf import settings
settings.configure()

def do_something_with_a_model():
    # does something with a model
    print "I am done!!"
</code></pre>

<p>Note that relative imports may break when running on single files.</p>

<p>(<em>for example. imports like <code>from .another_module import AnotherClass</code> may break when working with single file.</em>)</p>

python django pycharm