django 1.10.5; Error with Postgis db as default backend - python

I am new to development generally and django. Currently I have the error below when I use the 'python manage.py runserver' command after changing Default Database Engine on setting to
DATABASES = {
'default': {
'ENGINE': 'django.contrib.gis.db.backends.postgis',
'NAME': 'agricom',
'USER': 'postgres',
'HOST': 'localhost',
'PASSWORD': 'pass',
'PORT': '5432',
}
}
I get the error below;
cannot import name 'GDALRaster' from 'django.contrib.gis.gdal'
(vrtenv_dj1-105) C:\Users\Kevin\Documents\Django_PJs\agricom>py manage.py runserver
Unhandled exception in thread started by <function check_errors.<locals>.wrapper
at 0x046C46F0>
Traceback (most recent call last):
File "C:\Users\Kevin\Documents\Django_PJs\vrtenv_dj1-105\lib\site-packages\django\db\utils.py", line 115, in load_backend
return import_module('%s.base' % backend_name)
File "C:\Users\Kevin\AppData\Local\Programs\Python\Python37-32\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "C:\Users\Kevin\Documents\Django_PJs\vrtenv_dj1-105\lib\site-packages\django\contrib\gis\db\backends\postgis\base.py", line 7, in <module>
from .operations import PostGISOperations
File "C:\Users\Kevin\Documents\Django_PJs\vrtenv_dj1-105\lib\site-packages\django\contrib\gis\db\backends\postgis\operations.py", line 7, in <module>
from django.contrib.gis.gdal import GDALRaster
ImportError: cannot import name 'GDALRaster' from 'django.contrib.gis.gdal' (C:\Users\Kevin\Documents\Django_PJs\vrtenv_dj1-105\lib\site-packages\django\contrib\gis\gdal\__init__.py)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\Kevin\Documents\Django_PJs\vrtenv_dj1-105\lib\site-packages\django\utils\autoreload.py", line 226, in wrapper
fn(*args, **kwargs)
File "C:\Users\Kevin\Documents\Django_PJs\vrtenv_dj1-105\lib\site-packages\django\core\management\commands\runserver.py", line 113, in inner_run
autoreload.raise_last_exception()
File "C:\Users\Kevin\Documents\Django_PJs\vrtenv_dj1-105\lib\site-packages\django\utils\autoreload.py", line 249, in raise_last_exception
six.reraise(*_exception)
File "C:\Users\Kevin\Documents\Django_PJs\vrtenv_dj1-105\lib\site-packages\django\utils\six.py", line 685, in reraise
raise value.with_traceback(tb)
File "C:\Users\Kevin\Documents\Django_PJs\vrtenv_dj1-105\lib\site-packages\django\utils\autoreload.py", line 226, in wrapper
fn(*args, **kwargs)
File "C:\Users\Kevin\Documents\Django_PJs\vrtenv_dj1-105\lib\site-packages\django\__init__.py", line 27, in setup
apps.populate(settings.INSTALLED_APPS)
File "C:\Users\Kevin\Documents\Django_PJs\vrtenv_dj1-105\lib\site-packages\django\apps\registry.py", line 108, in populate
app_config.import_models(all_models)
File "C:\Users\Kevin\Documents\Django_PJs\vrtenv_dj1-105\lib\site-packages\django\apps\config.py", line 199, in import_models
self.models_module = import_module(models_module_name)
File "C:\Users\Kevin\AppData\Local\Programs\Python\Python37-32\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "C:\Users\Kevin\Documents\Django_PJs\vrtenv_dj1-105\lib\site-packages\django\contrib\auth\models.py", line 4, in <module>
from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager
File "C:\Users\Kevin\Documents\Django_PJs\vrtenv_dj1-105\lib\site-packages\django\contrib\auth\base_user.py", line 52, in <module>
class AbstractBaseUser(models.Model):
File "C:\Users\Kevin\Documents\Django_PJs\vrtenv_dj1-105\lib\site-packages\django\db\models\base.py", line 119, in __new__
new_class.add_to_class('_meta', Options(meta, app_label))
File "C:\Users\Kevin\Documents\Django_PJs\vrtenv_dj1-105\lib\site-packages\django\db\models\base.py", line 316, in add_to_class
value.contribute_to_class(cls, name)
File "C:\Users\Kevin\Documents\Django_PJs\vrtenv_dj1-105\lib\site-packages\django\db\models\options.py", line 214, in contribute_to_class
self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())
File "C:\Users\Kevin\Documents\Django_PJs\vrtenv_dj1-105\lib\site-packages\django\db\__init__.py", line 33, in __getattr__
return getattr(connections[DEFAULT_DB_ALIAS], item)
File "C:\Users\Kevin\Documents\Django_PJs\vrtenv_dj1-105\lib\site-packages\django\db\utils.py", line 211, in __getitem__
backend = load_backend(db['ENGINE'])
File "C:\Users\Kevin\Documents\Django_PJs\vrtenv_dj1-105\lib\site-packages\django\db\utils.py", line 134, in load_backend
raise ImproperlyConfigured(error_msg)
django.core.exceptions.ImproperlyConfigured: 'django.contrib.gis.db.backends.postgis' isn't an available database backend.
Try using 'django.db.backends.XXX', where XXX is one of:
'mysql', 'oracle', 'postgresql', 'sqlite3'
Error was: cannot import name 'GDALRaster' from 'django.contrib.gis.gdal' (C:\Users\Kevin\Documents\Django_PJs\vrtenv_dj1-105\lib\site-packages\django\contrib\gis\gdal\__init__.py)
What can I do?
Please find error message below:

Related

Getting error while running heroku run python manage.py migrate

I am a beginner in heroku and django and I am trying to create an application. While I was importing my database to heroku by running command -
heroku run python manage.py migrate
I get an error saying -
Traceback (most recent call last):
File "/app/.heroku/python/lib/python3.9/site-packages/django/core/management/base.py", line 373, in run_from_argv
self.execute(*args, **cmd_options)
File "/app/.heroku/python/lib/python3.9/site-packages/django/core/management/base.py", line 417, in execute
output = self.handle(*args, **options)
File "/app/.heroku/python/lib/python3.9/site-packages/django/core/management/base.py", line 87, in wrapped
saved_locale = translation.get_language()
File "/app/.heroku/python/lib/python3.9/site-packages/django/utils/translation/__init__.py", line 182, in get_language
return _trans.get_language()
File "/app/.heroku/python/lib/python3.9/site-packages/django/utils/translation/__init__.py", line 50, in __getattr__
if settings.USE_I18N:
File "/app/.heroku/python/lib/python3.9/site-packages/django/conf/__init__.py", line 84, in __getattr__
self._setup(name)
File "/app/.heroku/python/lib/python3.9/site-packages/django/conf/__init__.py", line 71, in _setup
self._wrapped = Settings(settings_module)
File "/app/.heroku/python/lib/python3.9/site-packages/django/conf/__init__.py", line 179, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "/app/.heroku/python/lib/python3.9/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 972, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 984, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'pp'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/app/manage.py", line 22, in <module>
main()
File "/app/manage.py", line 18, in main
execute_from_command_line(sys.argv)
File "/app/.heroku/python/lib/python3.9/site-packages/django/core/management/__init__.py", line 425, in execute_from_command_line
utility.execute()
File "/app/.heroku/python/lib/python3.9/site-packages/django/core/management/__init__.py", line 419, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/app/.heroku/python/lib/python3.9/site-packages/django/core/management/base.py", line 386, in run_from_argv
connections.close_all()
File "/app/.heroku/python/lib/python3.9/site-packages/django/db/utils.py", line 208, in close_all
for alias in self:
File "/app/.heroku/python/lib/python3.9/site-packages/django/utils/connection.py", line 73, in __iter__
return iter(self.settings)
File "/app/.heroku/python/lib/python3.9/site-packages/django/utils/functional.py", line 48, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/app/.heroku/python/lib/python3.9/site-packages/django/utils/connection.py", line 45, in settings
self._settings = self.configure_settings(self._settings)
File "/app/.heroku/python/lib/python3.9/site-packages/django/db/utils.py", line 144, in configure_settings
databases = super().configure_settings(databases)
File "/app/.heroku/python/lib/python3.9/site-packages/django/utils/connection.py", line 50, in configure_settings
settings = getattr(django_settings, self.settings_name)
File "/app/.heroku/python/lib/python3.9/site-packages/django/conf/__init__.py", line 84, in __getattr__
self._setup(name)
File "/app/.heroku/python/lib/python3.9/site-packages/django/conf/__init__.py", line 71, in _setup
self._wrapped = Settings(settings_module)
File "/app/.heroku/python/lib/python3.9/site-packages/django/conf/__init__.py", line 179, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "/app/.heroku/python/lib/python3.9/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 972, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 984, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'pp'
What should I do to successfully import my database to heroku and get it working? Please let me know if I need to add any of my files on here.
This is my directory layout in visual studio code -
Django directory

I have a problem with Django, with the manage.py file

I just began with Django, I'm following the steps of a youtube tutorial, but when I want to run this command:
python manage.py runserver
This is the error message:
Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x03E82780>
Traceback (most recent call last):
File "D:\Personal\Dev\cfehome\lib\site-packages\django\utils\autoreload.py", line 228, in wrapper
fn(*args, **kwargs)
File "D:\Personal\Dev\cfehome\lib\site-packages\django\core\management\commands\runserver.py", line 117, in inner_run
autoreload.raise_last_exception()
File "D:\Personal\Dev\cfehome\lib\site-packages\django\utils\autoreload.py", line 251, in raise_last_exception
six.reraise(*_exception)
File "D:\Personal\Dev\cfehome\lib\site-packages\django\utils\six.py", line 685, in reraise
raise value.with_traceback(tb)
File "D:\Personal\Dev\cfehome\lib\site-packages\django\utils\autoreload.py", line 228, in wrapper
fn(*args, **kwargs)
File "D:\Personal\Dev\cfehome\lib\site-packages\django\__init__.py", line 27, in setup
apps.populate(settings.INSTALLED_APPS)
File "D:\Personal\Dev\cfehome\lib\site-packages\django\apps\registry.py", line 85, in populate
app_config = AppConfig.create(entry)
File "D:\Personal\Dev\cfehome\lib\site-packages\django\apps\config.py", line 94, in create
module = import_module(entry)
File "D:\Personal\Dev\cfehome\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "D:\Personal\Dev\cfehome\lib\site-packages\django\contrib\admin\__init__.py", line 4, in <module>
from django.contrib.admin.filters import (
File "D:\Personal\Dev\cfehome\lib\site-packages\django\contrib\admin\filters.py", line 10, in <module>
from django.contrib.admin.options import IncorrectLookupParameters
File "D:\Personal\Dev\cfehome\lib\site-packages\django\contrib\admin\options.py", line 12, in <module>
from django.contrib.admin import helpers, widgets
File "D:\Personal\Dev\cfehome\lib\site-packages\django\contrib\admin\widgets.py", line 151
'%s=%s' % (k, v) for k, v in params.items(),
^
SyntaxError: Generator expression must be parenthesized
Do someone know how can I solve this error?
Follow the path in Your Django App
D:\Personal\Dev\cfehome\lib\site-packages\django\contrib\admin\widgets.py
Next step in line no.151 :
('%s=%s' % (k, v) for k, v in params.items())
You must have to parenthesize this.

Exceptions: Django 1.8 with MSSQL Server 2017 offline

As I'm new to Django. I have installed Django = 1.8 version. I tried with MSSQL Server 2017 which is locally installed in standalone system. Apart from settings.py file I had not modified anything. It is showing ImproperlyConfigured: Django 1.11 is not supported even though i had used Django 1.8 version.
Settings.py
DATABASES = {
'default': {
'ENGINE': 'django_pyodbc',
'HOST': '127.0.0.1',
'NAME': 'demo2016',
'USER': '',
'PASSWORD': '',
'PORT': '',
'OPTIONS': {
'driver': 'ODBC Driver 13 for SQL Server',
},
}
}
C:\Users\Vitriv-Desktop\Desktop\sqldjango>python manage.py migrate
Traceback (most recent call last):
File "manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
File "C:\Users\Vitriv-Desktop\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\__init__.py", line 364, in execute_from_command_line
utility.execute()
File "C:\Users\Vitriv-Desktop\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\__init__.py", line 338, in execute
django.setup()
File "C:\Users\Vitriv-Desktop\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\__init__.py", line 27, in setup
apps.populate(settings.INSTALLED_APPS)
File "C:\Users\Vitriv-Desktop\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\apps\registry.py", line 108, in populate
app_config.import_models()
File "C:\Users\Vitriv-Desktop\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\apps\config.py", line 202, in import_models
self.models_module = import_module(models_module_name)
File "C:\Users\Vitriv-Desktop\AppData\Local\Programs\Python\Python36-32\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "C:\Users\Vitriv-Desktop\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\contrib\auth\models.py", line 4, in <module>
from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager
File "C:\Users\Vitriv-Desktop\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\contrib\auth\base_user.py", line 52, in <module>
class AbstractBaseUser(models.Model):
File "C:\Users\Vitriv-Desktop\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\models\base.py", line 124, in __new__
new_class.add_to_class('_meta', Options(meta, app_label))
File "C:\Users\Vitriv-Desktop\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\models\base.py", line 325, in add_to_class
value.contribute_to_class(cls, name)
File "C:\Users\Vitriv-Desktop\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\models\options.py", line 214, in contribute_to_class
self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())
File "C:\Users\Vitriv-Desktop\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\__init__.py", line 33, in __getattr__
return getattr(connections[DEFAULT_DB_ALIAS], item)
File "C:\Users\Vitriv-Desktop\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\utils.py", line 211, in __getitem__
backend = load_backend(db['ENGINE'])
File "C:\Users\Vitriv-Desktop\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\utils.py", line 115, in load_backend
return import_module('%s.base' % backend_name)
File "C:\Users\Vitriv-Desktop\AppData\Local\Programs\Python\Python36-32\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "C:\Users\Vitriv-Desktop\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django_pyodbc\base.py", line 98, in <module>
raise ImproperlyConfigured("Django %d.%d is not supported." % DjangoVersion[:2])
django.core.exceptions.ImproperlyConfigured: Django 1.11 is not supported.
How should I try to resolve the above issue?

Python 3.5.2 error UndefinedValueError

My application is configured for use mysql, but when i try to run ./manage.py migrate this error ocours
root#renato-VirtualBox:/home/renato/unb-alerta# ./manage.py migrate
Traceback (most recent call last):
File "./manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/home/renato/unb-alerta/venv/lib/python3.5/site- packages/django/core/management/__init__.py", line 367, in execute_from_command_line
utility.execute()
File "/home/renato/unb-alerta/venv/lib/python3.5/site- packages/django/core/management/__init__.py", line 316, in execute
settings.INSTALLED_APPS
File "/home/renato/unb-alerta/venv/lib/python3.5/site- packages/django/conf/__init__.py", line 53, in __getattr__
self._setup(name)
File "/home/renato/unb-alerta/venv/lib/python3.5/site-packages/django/conf/__init__.py", line 41, in _setup
self._wrapped = Settings(settings_module)
File "/home/renato/unb-alerta/venv/lib/python3.5/site- packages/django/conf/__init__.py", line 97, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "/home/renato/unb- alerta/venv/lib/python3.5/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 986, in _gcd_import
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 665, in exec_module
File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
File "/home/renato/unb-alerta/unb_alerta/settings.py", line 139, in <module>
cast=db_url,
File "/home/renato/unb-alerta/venv/lib/python3.5/site- packages/decouple.py", line 197, in __call__
return self.config(*args, **kwargs)
File "/home/renato/unb-alerta/venv/lib/python3.5/site- packages/decouple.py", line 77, in __call__
return self.get(*args, **kwargs)
File "/home/renato/unb-alerta/venv/lib/python3.5/site- packages/decouple.py", line 64, in get
raise UndefinedValueError('%s option not found and default value was not defined.' % option)
decouple.UndefinedValueError: DATABASE_URL option not found and default value was not defined.
My .env have DATABASE_URL end my settings.py has this configuration
DATABASES = {
'default': config(
'DATABASE_URL',
cast=db_url,
)
}

can't get pymysql to work with my python 3.4.1 environment

I might be doing something obvious wrong but I've been stock for a long time and have to get help. So sorry if it's obvious and stupid.
Can someone please take a look at this? I really appreciate the help.
I have python3.4.1 and need to use pymysql but the syncdb fails:
> (yara-proj)~/django-projects/yara-project/yaraSite$> python manage.py syncdb
Traceback (most recent call last):
File "/Users/Gemeni/.virtualenvs/yara-proj/lib/python3.4/site-packages/django/db/utils.py", line 113, in load_backend
return import_module('%s.base' % backend_name)
File "/Users/Gemeni/.virtualenvs/yara-proj/lib/python3.4/importlib/__init__.py", line 109, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 2254, in _gcd_import
File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
File "<frozen importlib._bootstrap>", line 2226, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 1191, in _load_unlocked
File "<frozen importlib._bootstrap>", line 1161, in _load_backward_compatible
File "/Users/Gemeni/.virtualenvs/yara-proj/lib/python3.4/site-packages/django_mysql_pymysql-0.1-py3.4.egg/mysql_pymysql/base.py", line 29, in <module>
ImportError: cannot import name 'SafeUnicode'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/Users/Gemeni/.virtualenvs/yara-proj/lib/python3.4/site-packages/django/core/management/__init__.py", line 399, in execute_from_command_line
utility.execute()
File "/Users/Gemeni/.virtualenvs/yara-proj/lib/python3.4/site-packages/django/core/management/__init__.py", line 392, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Users/Gemeni/.virtualenvs/yara-proj/lib/python3.4/site-packages/django/core/management/base.py", line 242, in run_from_argv
self.execute(*args, **options.__dict__)
File "/Users/Gemeni/.virtualenvs/yara-proj/lib/python3.4/site-packages/django/core/management/base.py", line 280, in execute
translation.activate('en-us')
File "/Users/Gemeni/.virtualenvs/yara-proj/lib/python3.4/site-packages/django/utils/translation/__init__.py", line 130, in activate
return _trans.activate(language)
File "/Users/Gemeni/.virtualenvs/yara-proj/lib/python3.4/site-packages/django/utils/translation/trans_real.py", line 188, in activate
_active.value = translation(language)
File "/Users/Gemeni/.virtualenvs/yara-proj/lib/python3.4/site-packages/django/utils/translation/trans_real.py", line 177, in translation
default_translation = _fetch(settings.LANGUAGE_CODE)
File "/Users/Gemeni/.virtualenvs/yara-proj/lib/python3.4/site-packages/django/utils/translation/trans_real.py", line 159, in _fetch
app = import_module(appname)
File "/Users/Gemeni/.virtualenvs/yara-proj/lib/python3.4/importlib/__init__.py", line 109, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 2254, in _gcd_import
File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
File "<frozen importlib._bootstrap>", line 2226, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 1200, in _load_unlocked
File "<frozen importlib._bootstrap>", line 1129, in _exec
File "<frozen importlib._bootstrap>", line 1471, in exec_module
File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed
File "/Users/Gemeni/.virtualenvs/yara-proj/lib/python3.4/site-packages/django/contrib/admin/__init__.py", line 6, in <module>
from django.contrib.admin.sites import AdminSite, site
File "/Users/Gemeni/.virtualenvs/yara-proj/lib/python3.4/site-packages/django/contrib/admin/sites.py", line 4, in <module>
from django.contrib.admin.forms import AdminAuthenticationForm
File "/Users/Gemeni/.virtualenvs/yara-proj/lib/python3.4/site-packages/django/contrib/admin/forms.py", line 6, in <module>
from django.contrib.auth.forms import AuthenticationForm
File "/Users/Gemeni/.virtualenvs/yara-proj/lib/python3.4/site-packages/django/contrib/auth/forms.py", line 17, in <module>
from django.contrib.auth.models import User
File "/Users/Gemeni/.virtualenvs/yara-proj/lib/python3.4/site-packages/django/contrib/auth/models.py", line 48, in <module>
class Permission(models.Model):
File "/Users/Gemeni/.virtualenvs/yara-proj/lib/python3.4/site-packages/django/db/models/base.py", line 96, in __new__
new_class.add_to_class('_meta', Options(meta, **kwargs))
File "/Users/Gemeni/.virtualenvs/yara-proj/lib/python3.4/site-packages/django/db/models/base.py", line 264, in add_to_class
value.contribute_to_class(cls, name)
File "/Users/Gemeni/.virtualenvs/yara-proj/lib/python3.4/site-packages/django/db/models/options.py", line 124, in contribute_to_class
self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())
File "/Users/Gemeni/.virtualenvs/yara-proj/lib/python3.4/site-packages/django/db/__init__.py", line 34, in __getattr__
return getattr(connections[DEFAULT_DB_ALIAS], item)
File "/Users/Gemeni/.virtualenvs/yara-proj/lib/python3.4/site-packages/django/db/utils.py", line 198, in __getitem__
backend = load_backend(db['ENGINE'])
File "/Users/Gemeni/.virtualenvs/yara-proj/lib/python3.4/site-packages/django/db/utils.py", line 131, in load_backend
raise ImproperlyConfigured(error_msg)
django.core.exceptions.ImproperlyConfigured: 'mysql_pymysql' isn't an available database backend.
Try using 'django.db.backends.XXX', where XXX is one of:
'mysql', 'oracle', 'postgresql_psycopg2', 'sqlite3'
Error was: cannot import name 'SafeUnicode'
Here's what I have in settings.py
# Database
# https://docs.djangoproject.com/en/1.6/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'mysql_pymysql',
'HOST': '127.0.0.1',
'USER': 'root',
'PASSWORD': 'root',
}
}
and this is how the environment is setup.
(yara-proj)~/django-projects/yara-project/yaraSite$> ls
manage.py yaraSite
(yara-proj)~/django-projects/yara-project/yaraSite$> cd yaraSite/
(yara-proj)~/django-projects/yara-project/yaraSite/yaraSite$> ls
__init__.py
pycache__
django-mysql-pymysql
settings.py
urls.py
wsgi.py
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'HOST': '127.0.0.1',
'USER': 'root'
'PASSWORD': 'root',
}
}
Is the answer. PyMySQL is not a supported backend. You need to install the C bindings python-MySQL to work with mysql and Django.
Or you can try the solution described here How to make Django work with unsupported MySQL drivers such as gevent-mysql or Concurrence's MySQL driver?

Categories

Resources