django unable to start runserver - django

unable to start C:\Python27\mysastha>python manage.py runserver
c:\python27\lib\site-packages\djangotoolbox-1.6.2-py2.7.egg\djangotoolbox\db\uti
ls.py:5: RemovedInDjango19Warning: django.utils.unittest will be removed in Djan
go 1.9.
from django.utils.unittest import skip
Traceback (most recent call last):
File "manage.py", line 17, in <module>
execute_from_command_line(sys.argv)
File "c:\python27\lib\site-packages\django-1.8-py2.7.egg\django\core\managemen
t\__init__.py", line 330, in execute_from_command_line
utility.execute()
File "c:\python27\lib\site-packages\django-1.8-py2.7.egg\django\core\managemen
t\__init__.py", line 304, in execute
django.setup()
File "c:\python27\lib\site-packages\django-1.8-py2.7.egg\django\__init__.py",
line 21, in setup
apps.populate(settings.INSTALLED_APPS)
File "c:\python27\lib\site-packages\django-1.8-py2.7.egg\django\apps\registry.
py", line 108, in populate
app_config.import_models(all_models)
File "c:\python27\lib\site-packages\django-1.8-py2.7.egg\django\apps\config.py
", line 197, in import_models
self.models_module = import_module(models_module_name)
File "c:\python27\lib\importlib\__init__.py", line 37, in import_module
__import__(name)
File "c:\python27\lib\site-packages\django-1.8-py2.7.egg\django\contrib\auth\m
odels.py", line 40, in <module>
class Permission(models.Model):
File "c:\python27\lib\site-packages\django-1.8-py2.7.egg\django\db\models\base
.py", line 127, in __new__
new_class.add_to_class('_meta', Options(meta, **kwargs))
File "c:\python27\lib\site-packages\django-1.8-py2.7.egg\django\db\models\base
.py", line 303, in add_to_class
value.contribute_to_class(cls, name)
File "c:\python27\lib\site-packages\django-1.8-py2.7.egg\django\db\models\opti
ons.py", line 166, in contribute_to_class
self.db_table = truncate_name(self.db_table, connection.ops.max_name_length(
))
File "c:\python27\lib\site-packages\django-1.8-py2.7.egg\django\db\__init__.py
", line 36, in __getattr__
return getattr(connections[DEFAULT_DB_ALIAS], item)
File "c:\python27\lib\site-packages\django-1.8-py2.7.egg\django\db\utils.py",
line 238, in __getitem__
backend = load_backend(db['ENGINE'])
File "c:\python27\lib\site-packages\django-1.8-py2.7.egg\django\db\utils.py",
line 127, in load_backend
raise ImproperlyConfigured(error_msg)
django.core.exceptions.ImproperlyConfigured: 'django_mongodb_engine' isn't an av
ailable database backend.
Try using 'django.db.backends.XXX', where XXX is one of:
u'django_mongodb_engine', u'mysql', u'oracle', u'postgresql_psycopg2', u'sql
ite3'
Error was: cannot import name decimal_to_string

Just follow the instructions in the trace back. you need django.db.backends.django_mongodb_engine as the engine. Not just django_mongodb_engine.
If you havent already you will probably need a couple dependencies for the engine to work. im on mobile and dont know what they are called at the moment for mongodb

Related

Django issue with gettext unable to read .mo files

To give a bit of context, I'm working in internship on the upgrade of a Django app from 1.4.22 to 1.11 and python 2 to 3.
The project wasn't well factored, and when I tried to refactor it, I got a strange stack :
Traceback (most recent call last):
File "/home/antonin/Developpement/Projet/djangoproject2/djangoproject/manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/home/antonin/Developpement/Projet/djangoproject2/venv/lib/python2.7/site-packages/django/core/management/__init__.py", line 385, in execute_from_command_line
utility.execute()
File "/home/antonin/Developpement/Projet/djangoproject2/venv/lib/python2.7/site-packages/django/core/management/__init__.py", line 354, in execute
django.setup()
File "/home/antonin/Developpement/Projet/djangoproject2/venv/lib/python2.7/site-packages/django/__init__.py", line 21, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/antonin/Developpement/Projet/djangoproject2/venv/lib/python2.7/site-packages/django/apps/registry.py", line 108, in populate
app_config.import_models(all_models)
File "/home/antonin/Developpement/Projet/djangoproject2/venv/lib/python2.7/site-packages/django/apps/config.py", line 202, in import_models
self.models_module = import_module(models_module_name)
File "/usr/lib64/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/home/antonin/Developpement/Projet/djangoproject2/djangoproject/instance/models.py", line 54, in <module>
YEARS += [(str(yr), _(u"n+%(year)d") % {'year': yr}) for yr in range(1, 20)]
File "/home/antonin/Developpement/Projet/djangoproject2/venv/lib/python2.7/site-packages/django/utils/functional.py", line 179, in __mod__
return six.text_type(self) % rhs
File "/home/antonin/Developpement/Projet/djangoproject2/venv/lib/python2.7/site-packages/django/utils/functional.py", line 144, in __text_cast
return func(*self.__args, **self.__kw)
File "/home/antonin/Developpement/Projet/djangoproject2/venv/lib/python2.7/site-packages/django/utils/translation/__init__.py", line 83, in ugettext
return _trans.ugettext(message)
File "/home/antonin/Developpement/Projet/djangoproject2/venv/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 325, in ugettext
return do_translate(message, 'ugettext')
File "/home/antonin/Developpement/Projet/djangoproject2/venv/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 306, in do_translate
_default = translation(settings.LANGUAGE_CODE)
File "/home/antonin/Developpement/Projet/djangoproject2/venv/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 209, in translation
default_translation = _fetch(settings.LANGUAGE_CODE)
File "/home/antonin/Developpement/Projet/djangoproject2/venv/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 195, in _fetch
res = _merge(apppath)
File "/home/antonin/Developpement/Projet/djangoproject2/venv/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 177, in _merge
t = _translation(path)
File "/home/antonin/Developpement/Projet/djangoproject2/venv/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 159, in _translation
t = gettext_module.translation('django', path, [loc], DjangoTranslation)
File "/usr/lib64/python2.7/gettext.py", line 554, in translation
t = _translations.setdefault(key, class_(fp))
File "/home/antonin/Developpement/Projet/djangoproject2/venv/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 107, in __init__
gettext_module.GNUTranslations.__init__(self, *args, **kw)
File "/usr/lib64/python2.7/gettext.py", line 255, in __init__
self._parse(fp)
File "/usr/lib64/python2.7/gettext.py", line 348, in _parse
magic = unpack('<I', buf[:4])[0]
struct.error: unpack requires a string argument of length 4
When I tried to debug, with step by step mode, I saw that the issue is at the line
File "/home/antonin/Developpement/Projet/djangoproject2/venv/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 107, in __init__
gettext_module.GNUTranslations.__init__(self, *args, **kw)
where fp.read() receive a u'path/to/file.po' (path which is correct) and return a empty buffer. But I don't see any reasons why this appens.
Edit : thanks, håken, it was Indeed the .mo files that were corrupted. Problem solved.

Django Upgrade From 1.8.8 to 1.11.13 Issue

I am getting the following error. I have added the sites framework, allowed the domain and updated the middleware and context processors but cant fathom this error. Any help would be appreciated as this is live at the minute.
manager#web-server:~/Websites/shen$ python manage.py migrate
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/lib/python2.7/dist-packages/django/core/management /__init__.py", line 364, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 338, in execute
django.setup()
File "/usr/local/lib/python2.7/dist-packages/django/__init__.py", line 27, in setup
apps.populate(settings.INSTALLED_APPS)
File "/usr/local/lib/python2.7/dist-packages/django/apps/registry.py", line 108, in populate
app_config.import_models()
File "/usr/local/lib/python2.7/dist-packages/django/apps/config.py", line 202, in import_models
self.models_module = import_module(models_module_name)
File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/usr/local/lib/python2.7/dist-packages/easy_thumbnails/models.py", line 6, in <module>
from easy_thumbnails import utils, signal_handlers
File "/usr/local/lib/python2.7/dist-packages/easy_thumbnails/utils.py", line 15, in <module>
from easy_thumbnails.conf import settings
File "/usr/local/lib/python2.7/dist-packages/easy_thumbnails/conf.py", line 334, in <module>
settings = Settings()
File "/usr/local/lib/python2.7/dist-packages/easy_thumbnails/conf.py", line 21, in __init__
super(AppSettings, self).__init__(*args, **kwargs)
TypeError: __init__() takes exactly 2 arguments (1 given)

python-django/python manage.py runserver error

I am trying to run the server using this command python manage.py runserver but i am getting this error even i have installed mysqlclient and mysql-python:
C:\Users\neethu\sencha\sencha-sdks\sencha_workspace\webapp>python manage.py runserver
Unhandled exception in thread started by <function wrapper at 0x0397EC70>
Traceback (most recent call last):
File "C:\Python27\lib\site-packages\django\utils\autoreload.py", line 228, in wrapper
fn(*args, **kwargs)
File "C:\Python27\lib\site-packages\django\core\management\commands\runserver.py", line 117, in inner_run
autoreload.raise_last_exception()
File "C:\Python27\lib\site-packages\django\utils\autoreload.py", line 251, in raise_last_exception
six.reraise(*_exception)
File "C:\Python27\lib\site-packages\django\utils\autoreload.py", line 228, in wrapper
fn(*args, **kwargs)
File "C:\Python27\lib\site-packages\django\__init__.py", line 27, in setup
apps.populate(settings.INSTALLED_APPS)
File "C:\Python27\lib\site-packages\django\apps\registry.py", line 108, in populate
app_config.import_models()
File "C:\Python27\lib\site-packages\django\apps\config.py", line 202, in import_models
self.models_module = import_module(models_module_name)
File "C:\Python27\lib\importlib\__init__.py", line 37, in import_module
__import__(name)
File "C:\Python27\lib\site-packages\django\contrib\auth\models.py", line 4, in <module>
from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager
File "C:\Python27\lib\site-packages\django\contrib\auth\base_user.py", line 52, in <module>
class AbstractBaseUser(models.Model):
File "C:\Python27\lib\site-packages\django\db\models\base.py", line 124, in __new__
new_class.add_to_class('_meta', Options(meta, app_label))
File "C:\Python27\lib\site-packages\django\db\models\base.py", line 325, in add_to_class
value.contribute_to_class(cls, name)
File "C:\Python27\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:\Python27\lib\site-packages\django\db\__init__.py", line 33, in __getattr__
return getattr(connections[DEFAULT_DB_ALIAS], item)
File "C:\Python27\lib\site-packages\django\db\utils.py", line 211, in __getitem__
backend = load_backend(db['ENGINE'])
File "C:\Python27\lib\site-packages\django\db\utils.py", line 115, in load_backend
return import_module('%s.base' % backend_name)
File "C:\Python27\lib\importlib\__init__.py", line 37, in import_module
__import__(name)
File "C:\Python27\lib\site-packages\django\db\backends\mysql\base.py", line 30, in <module>
'Did you install mysqlclient or MySQL-python?' % e
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: DLL load failed: %1 is not a valid Win32 application..
Did you install mysqlclient or MySQL-python?

I'm getting an error while creating Python Django Project

C:\Python27\Scripts>django-admin startproject python_tutorial
Traceback (most recent call last):
File "c:\python27\lib\runpy.py", line 162, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "c:\python27\lib\runpy.py", line 72, in _run_code
exec code in run_globals
File "C:\Python27\Scripts\django-admin.exe\__main__.py", line 9, in <module>
File "c:\python27\lib\site-packages\django\core\management\__init__.py", line 367, in execute_from_command_line
utility.execute()
File "c:\python27\lib\site-packages\django\core\management\__init__.py", line 316, in execute
settings.INSTALLED_APPS
File "c:\python27\lib\site-packages\django\conf\__init__.py", line 53, in __getattr__
self._setup(name)
File "c:\python27\lib\site-packages\django\conf\__init__.py", line 41, in _setup
self._wrapped = Settings(settings_module)
File "c:\python27\lib\site-packages\django\conf\__init__.py", line 97, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "c:\python27\lib\importlib\__init__.py", line 37, in import_module
__import__(name)
ImportError: Import by filename is not supported.
Can someone please suggest what to do?
By mistake I have set variable "DJANGO_SETTINGS_MODULE" to python path and it messed up. I have deleted this environment variable and it works.

django exception: libperconaserverclient.so.18: cannot open shared object file: No such file or directory

I am new to django.
I get this error when I update settings.py with database and run
$python2.7 manage.py migrate
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb
module: libperconaserverclient.so.18: cannot open shared object file:
No such file or directory
Is it because of version of mysql ? if so which version should I use ?
$ python2.7 manage.py migrate
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/home/sachints/project/env/lib/python2.7/site-packages/django/core/management/__init__.py", line 353, in execute_from_command_line
utility.execute()
File "/home/sachints/project/env/lib/python2.7/site-packages/django/core/management/__init__.py", line 327, in execute
django.setup()
File "/home/sachints/project/env/lib/python2.7/site-packages/django/__init__.py", line 18, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/sachints/project/env/lib/python2.7/site-packages/django/apps/registry.py", line 108, in populate
app_config.import_models(all_models)
File "/home/sachints/project/env/lib/python2.7/site-packages/django/apps/config.py", line 202, in import_models
self.models_module = import_module(models_module_name)
File "/usr/local/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/home/sachints/project/env/lib/python2.7/site-packages/django/contrib/auth/models.py", line 4, in <module>
from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager
File "/home/sachints/project/env/lib/python2.7/site-packages/django/contrib/auth/base_user.py", line 49, in <module>
class AbstractBaseUser(models.Model):
File "/home/sachints/project/env/lib/python2.7/site-packages/django/db/models/base.py", line 108, in __new__
new_class.add_to_class('_meta', Options(meta, app_label))
File "/home/sachints/project/env/lib/python2.7/site-packages/django/db/models/base.py", line 299, in add_to_class
value.contribute_to_class(cls, name)
File "/home/sachints/project/env/lib/python2.7/site-packages/django/db/models/options.py", line 263, in contribute_to_class
self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())
File "/home/sachints/project/env/lib/python2.7/site-packages/django/db/__init__.py", line 36, in __getattr__
return getattr(connections[DEFAULT_DB_ALIAS], item)
File "/home/sachints/project/env/lib/python2.7/site-packages/django/db/utils.py", line 212, in __getitem__
backend = load_backend(db['ENGINE'])
File "/home/sachints/project/env/lib/python2.7/site-packages/django/db/utils.py", line 116, in load_backend
return import_module('%s.base' % backend_name)
File "/usr/local/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/home/sachints/project/env/lib/python2.7/site-packages/django/db/backends/mysql/base.py", line 28, in <module>
raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: libperconaserverclient.so.18: cannot open shared object file: No such file or directory
I am using RHEL 6.7, MySql Server version: 5.1.73 and Python 2.7.11
yum -y install mysql-devel
ln -s /usr/local/mysql/lib/libperconaserverclient_r.so.18 /usr/lib
ln -s /usr/local/mysql/lib/libperconaserverclient_r.so /usr/lib
Idconifg
done!