[Django]-Django import client

5👍

Try this:

import os
import sys

sys.path.append('/home/username/www/site_folder')
os.environ['DJANGO_SETTINGS_MODULE'] = 'project.settings'


from django.utils import unittest
from django.utils import simplejson as json
from django.test.client import Client

But replace project with folder name, where your settings.py is

👤imkost

4👍

The Client is looking for the settings.py. You could simply load the client by typing this in your project folder:

python manage.py shell

0👍

In Pycharm which I use, after following this Running Django tests in PyCharm
my problem was solved.

It’s in the file > settings > Django Support, and then select the right settings.

Leave a comment