How do I solve “django.core.exceptions.ImproperlyConfigured: Could not find the GDAL library” when running PyCharm test?

General Tech Bugs & Fixes 2 years ago

0 2 0 0 0 tuteeHUB earn credit +10 pts

5 Star Rating 1 Rating

Posted on 16 Aug 2022, this text provides information on Bugs & Fixes related to General Tech. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.

Take Quiz To Earn Credits!

Turn Your Knowledge into Earnings.

tuteehub_quiz

Answers (2)

Post Answer
profilepic.png
manpreet Tuteehub forum best answer Best Answer 2 years ago

 

I'm using Django, Python 3.7. and PyCharm 2018.3.5. I have this test file ...

./web/tests/view_tests.py

It looks like the below

# Basic test to verify we can get valid return data
def test_calculate_tax(self):
    state = 'MN'
    gross = 100000
    salary = 75000
    json_data = json.dumps({'state': state,
                            'gross': gross,
                            'salary': salary})

    response = c.post('/content/vote/', json_data,
                      content_type='application/json',
                      HTTP_X_REQUESTED_WITH='XMLHttpRequest')
    self.assertEqual(response.status_code, 302)  # this is OK.
    print(response.content)
    self.assertEqual(response.content, 2)

When I right click the test name in PyCharm and select the "Run Test" option, though, I get the below error. I have no idea what it means or how to fix it ...

Traceback (most recent call last):
  File "/Applications/PyCharm.app/Contents/helpers/pycharm/django_test_manage.py", line 56, in <module>
    django.setup()
  File "/Users/davea/Documents/workspace/myproject/venv/lib/python3.7/site-packages/django/__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/Users/davea/Documents/workspace/myproject/venv/lib/python3.7/site-packages/django/apps/registry.py", line 114, in populate
    app_config.import_models()
  File "/Users/davea/Documents/workspace/myproject/venv/lib/python3.7/site-packages/django/apps/config.py", line 211, in import_models
    self.models_module = import_module(models_module_name)
  File "/usr/local/Cellar/python/3.7.2_2/Frameworks/Python.framework/Versions/3.7/lib/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "", line 1006, in _gcd_import
  File "", line 983, in _find_and_load
  File "", line 967, in _find_and_load_unlocked
  File "", line 677, in _load_unlocked
  File "", line 728, in exec_module
  File "", line 219, in _call_with_frames_removed
  File "/Users/davea/Documents/workspace/myproject/web/models.py", line 2, 
                                                
                                                
0 views
0 shares
profilepic.png
manpreet 2 years ago

It looks like this a job on the frontend, and you should use DataTable's columns.render feature.

Example:

var responseObj = [
    { "information": "A1", "weblink": "http://www.microsoft.com" },
    { "information": "A2", "weblink": "http://www.yahoo.com" },
    { "information": "A3", "weblink": "http://www.google.com" },
    { "information": "A4", "weblink": "http://www.duckduckgo.com" }
];

$('#example').dataTable({
   "data": responseObj,
   "columns": [
      { "data": "information" }, 
      { 
         "data": "weblink",
         "render": function(data, type, row, meta){
            if(type === 'display'){
                data = '+ data + '">' + data + '';
            }

            return data;
         }
      } 
   ]
});

0 views   0 shares

No matter what stage you're at in your education or career, TuteeHub will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.