I installed johnny-cache 1.4 in Django 1.6 using the instructions but does not work:
# add johnny's middleware
MIDDLEWARE_CLASSES = (
'johnny.middleware.LocalStoreClearMiddleware',
'johnny.middleware.QueryCacheMiddleware',
# ...
)
# some johnny settings
CACHES = {
'default' : dict(
BACKEND = 'johnny.backends.memcached.MemcachedCache',
LOCATION = ['127.0.0.1:11211'],
JOHNNY_CACHE = True,
)
}
JOHNNY_MIDDLEWARE_KEY_PREFIX='jc_myproj'
the error that comes out is:
$ python manage.py runserver
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/home/diegoug/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 399, in execute_from_command_line
utility.execute()
File "/home/diegoug/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 392, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/diegoug/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 272, in fetch_command
klass = load_command_class(app_name, subcommand)
File "/home/diegoug/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 75, in load_command_class
module = import_module('%s.management.commands.%s' % (app_name, name))
File "/home/diegoug/local/lib/python2.7/site-packages/django/utils/importlib.py", line 40, in import_module
__import__(name)
File "/home/diegoug/local/lib/python2.7/site-packages/django/contrib/staticfiles/management/commands/runserver.py", line 6, in <module>
from django.contrib.staticfiles.handlers import StaticFilesHandler
File "/home/diegoug/local/lib/python2.7/site-packages/django/contrib/staticfiles/handlers.py", line 8, in <module>
from django.contrib.staticfiles.views import serve
File "/home/diegoug/local/lib/python2.7/site-packages/django/contrib/staticfiles/views.py", line 15, in <module>
from django.contrib.staticfiles import finders
File "/home/diegoug/local/lib/python2.7/site-packages/django/contrib/staticfiles/finders.py", line 12, in <module>
from django.contrib.staticfiles.storage import AppStaticStorage
File "/home/diegoug/local/lib/python2.7/site-packages/django/contrib/staticfiles/storage.py", line 8, in <module>
from django.core.cache import (get_cache, InvalidCacheBackendError,
File "/home/diegoug/local/lib/python2.7/site-packages/django/core/cache/__init__.py", line 138, in <module>
cache = get_cache(DEFAULT_CACHE_ALIAS)
File "/home/diegoug/local/lib/python2.7/site-packages/django/core/cache/__init__.py", line 130, in get_cache
"Could not find backend '%s': %s" % (backend, e))
django.core.cache.backends.base.InvalidCacheBackendError: Could not find backend 'johnny.backends.memcached.MemcachedCache': 'module' object has no attribute 'CacheClass'
Investigate and say the problem is more of Django, I would like to fix it, because this is a great tool and it would be great help.
Upgrade to Django version 1.7 which updated today, continuing the same problem, what I did was upgrade to version johnny cache development:
johnny-cache==1.6.1a
python-memcached==1.53
with this I am resolved the problem temporarily until they update
Related
I was running my project using Django 1.8 and it was working properly. But then I had to upgrade Django to 1.9 now when I again run my project it gave an error - ImportError: cannot import name get_cache.
python manage.py syncdb
and I get following:
Traceback (most recent call last):
File "manage.py", line 10, in <module> execute_from_command_line(sys.argv)
File "/home/vermahim17/env/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 350,
in execute_from_command_line utility.execute()
File "/home/vermahim17/env/local/lib/python2.7/site-packages/django/core/management/__init__.py",
line 324, in execute django.setup()
File "/home/vermahim17/env/local/lib/python2.7/site-packages/django/__init__.py",
line 18, in setup apps.populate(settings.INSTALLED_APPS)
File "/home/vermahim17/env/local/lib/python2.7/site-packages/django/apps/registry.py",
line 85, in populate app_config = AppConfig.create(entry)
File "/home/vermahim17/env/local/lib/python2.7/site-packages/django/apps/config.py",
line 90, in create module = import_module(entry)
File "/usr/lib/python2.7/importlib/__init__.py",
line 37, in import_module __import__(name)
File "/home/vermahim17/env/local/lib/python2.7/site-packages/keyedcache/__init__.py",
line 27, in <module>
from django.core.cache import get_cache, InvalidCacheBackendError, DEFAULT_CACHE_ALIAS ImportError: cannot import name get_cache
I think , Django 1.9 doesn't have the provision to import get_cache method. Please look into this to fix
https://github.com/vstoykov/django-imagekit/commit/c26f8a0
New to django… Since a month i'm trying to follow this tutorial without success. When i syncdb i get following error:
(virt-inplaceedit)Mac:testing manuelstrasser$ python manage.py syncdb
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/Users/manuelstrasser/Desktop/inplace/virt-inplaceedit/lib/python2.7/site-packages/django/core/management/__init__.py", line 385, in execute_from_command_line
utility.execute()
File "/Users/manuelstrasser/Desktop/inplace/virt-inplaceedit/lib/python2.7/site-packages/django/core/management/__init__.py", line 354, in execute
django.setup()
File "/Users/manuelstrasser/Desktop/inplace/virt-inplaceedit/lib/python2.7/site-packages/django/__init__.py", line 21, in setup
apps.populate(settings.INSTALLED_APPS)
File "/Users/manuelstrasser/Desktop/inplace/virt-inplaceedit/lib/python2.7/site-packages/django/apps/registry.py", line 85, in populate
app_config = AppConfig.create(entry)
File "/Users/manuelstrasser/Desktop/inplace/virt-inplaceedit/lib/python2.7/site-packages/django/apps/config.py", line 123, in create
import_module(entry)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/Users/manuelstrasser/Desktop/inplace/virt-inplaceedit/lib/python2.7/site-packages/sorl/thumbnail/__init__.py", line 1, in <module>
from sorl.thumbnail.fields import ImageField
File "/Users/manuelstrasser/Desktop/inplace/virt-inplaceedit/lib/python2.7/site-packages/sorl/thumbnail/fields.py", line 6, in <module>
from sorl.thumbnail import default
File "/Users/manuelstrasser/Desktop/inplace/virt-inplaceedit/lib/python2.7/site-packages/sorl/thumbnail/default.py", line 3, in <module>
from sorl.thumbnail.helpers import get_module_class
File "/Users/manuelstrasser/Desktop/inplace/virt-inplaceedit/lib/python2.7/site-packages/sorl/thumbnail/helpers.py", line 5, in <module>
from django.utils import simplejson
ImportError: cannot import name simplejson
I installed simplejson but still same error. Anyone haveing experiences with this tutorial? I did everything exactly as per description…
django.utils.simplejson is deprecated in django 1.7.
Looks like you use old version of the sorl-thumbnail. Current version of sorl-thumbnail supports django 1.7 so try to update this library.
Just tried integrating Lettuce into my django installation and getting the following error:
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/var/www/abc/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 399, in execute_from_command_line
utility.execute()
File "/var/www/abc/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 392, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/var/www/abc/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 272, in fetch_command
klass = load_command_class(app_name, subcommand)
File "/var/www/abc/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 75, in load_command_class
module = import_module('%s.management.commands.%s' % (app_name, name))
File "/var/www/abc/local/lib/python2.7/site-packages/django/utils/importlib.py", line 40, in import_module
__import__(name)
File "/var/www/abc/local/lib/python2.7/site-packages/lettuce/django/__init__.py", line 19, in <module>
from lettuce.django.server import Server
File "/var/www/abc/local/lib/python2.7/site-packages/lettuce/django/server.py", line 33, in <module>
from django.core.servers.basehttp import WSGIServerException
ImportError: cannot import name WSGIServerException
I heard that WSGIServerException was removed from django, so how do I get around this?
It's fixed on branch master, but it not yet available on PyPI.
You can simply install it from the source:
pip install -e git+https://github.com/gabrielfalcao/lettuce.git#egg=lettuce
the doc
The undocumented django.core.servers.basehttp.WSGIServerException has
been removed. Use socket.error provided by the standard library
instead.
i think you can tell "lettuce"'s author,0.0 .or: update "lettuce" python package.
I am trying to build a web app with GAE, Django. The user registration would be userena. I already use the django-nonrel and all the setup to get the first part working and I am trying to syncdb for userena. I am keep getting this errors, Could you please help me on this.
BB8265:epapyri-django$ sudo django-admin.py syncdb
Password:
Traceback (most recent call last):
File "/usr/local/bin/django-admin.py", line 5, in <module>
management.execute_from_command_line()
File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 443, in execute_from_command_line
utility.execute()
File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 382, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 261, in fetch_command
klass = load_command_class(app_name, subcommand)
File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 69, in load_command_class
module = import_module('%s.management.commands.%s' % (app_name, name))
File "/Library/Python/2.7/site-packages/django/utils/importlib.py", line 35, in import_module
__import__(name)
File "/Library/Python/2.7/site-packages/django/core/management/commands/syncdb.py", line 8, in <module>
from django.core.management.sql import custom_sql_for_model, emit_post_sync_signal
File "/Library/Python/2.7/site-packages/django/core/management/sql.py", line 6, in <module>
from django.db import models
File "/Library/Python/2.7/site-packages/django/db/__init__.py", line 11, in <module>
if DEFAULT_DB_ALIAS not in settings.DATABASES:
File "/Library/Python/2.7/site-packages/django/utils/functional.py", line 184, in inner
self._setup()
File "/Library/Python/2.7/site-packages/django/conf/__init__.py", line 40, in _setup
raise ImportError("Settings cannot be imported, because environment variable %s is undefined." % ENVIRONMENT_VARIABLE)
ImportError: Settings cannot be imported, because environment variable DJANGO_SETTINGS_MODULE is undefined.
settings.py and manage.py are in the same directory and I did not have this issue before adding this plugin.
the settings.py for database section is as follows:
# Activate django-dbindexer for the default database
DATABASES['native'] = DATABASES['default']
DATABASES['default'] = {'ENGINE': 'dbindexer', 'TARGET': 'native'}
AUTOLOAD_SITECONF = 'indexes'
INSTALLED_APPS = (
# 'django.contrib.admin',
'django.contrib.contenttypes',
'django.contrib.auth',
'django.contrib.sessions',
'djangotoolbox',
'autoload',
'dbindexer',
# social_auth
'httplib2',
'openid',
'oauth2',
'social_auth',
#userena
'userena',
'guardian',
'easy_thumbnails',
'accounts',
# djangoappengine should come last, so it can override a few manage.py commands
'djangoappengine',
)
and this is once I runserver
BB8265:epapyri-django$ sudo django-admin.py runserver
Traceback (most recent call last):
File "/usr/local/bin/django-admin.py", line 5, in <module>
management.execute_from_command_line()
File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 443, in execute_from_command_line
utility.execute()
File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 382, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 261, in fetch_command
klass = load_command_class(app_name, subcommand)
File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 69, in load_command_class
module = import_module('%s.management.commands.%s' % (app_name, name))
File "/Library/Python/2.7/site-packages/django/utils/importlib.py", line 35, in import_module
__import__(name)
File "/Library/Python/2.7/site-packages/django/core/management/commands/runserver.py", line 8, in <module>
from django.core.servers.basehttp import AdminMediaHandler, run, WSGIServerException, get_internal_wsgi_application
File "/Library/Python/2.7/site-packages/django/core/servers/basehttp.py", line 26, in <module>
from django.views import static
File "/Library/Python/2.7/site-packages/django/views/static.py", line 95, in <module>
template_translatable = ugettext_noop(u"Index of %(directory)s")
File "/Library/Python/2.7/site-packages/django/utils/translation/__init__.py", line 75, in gettext_noop
return _trans.gettext_noop(message)
File "/Library/Python/2.7/site-packages/django/utils/translation/__init__.py", line 48, in __getattr__
if settings.USE_I18N:
File "/Library/Python/2.7/site-packages/django/utils/functional.py", line 184, in inner
self._setup()
File "/Library/Python/2.7/site-packages/django/conf/__init__.py", line 40, in _setup
raise ImportError("Settings cannot be imported, because environment variable %s is undefined." % ENVIRONMENT_VARIABLE)
ImportError: Settings cannot be imported, because environment variable DJANGO_SETTINGS_MODULE is undefined.
[edited]
I remove the non django project from INSTALL_APP, import the django.models to my accounts/MyProfile, and chmod 777 on the .datastore since it shouldn't ask for permission every time modify it.
{File "/git/ePapyri/epapyri-django/djangoappengine/db/base.py", line 160, in _value_for_db
raise DatabaseError("Only strings and positive integers "
django.db.utils.DatabaseError: Only strings and positive integers may be used as keys on GAE.}
Why are you using django-admin.py to run syncdb and runserver? You should be using manage.py.
And you should definitely not be using sudo to run either of these.
(Also note your INSTALLED_APPS seems to be nonsense: it contains a whole lot of plain Python libraries like httplib2 and oauth2 which have no business at all being there.)
Edited
Firstly, you should have edited your question to add the traceback.
Secondly, the error message is very clear: you have not imported django.db.models in your accounts/models.py file.
Thirdly, it is still nonsense to include non-Django libraries in INSTALLED_APPS. There is simply no need to do so. And your datastore should not have been created with sudo in the first place - either delete and recreate it, or use chmod to make it accessible to a normal user.
I find out the problem is solved by adding a PIL to libraries in GAE, and yaml file would solve the issue, since it was complaining about image library in python. the link to all supported libraries for django is https://developers.google.com/appengine/docs/python/tools/libraries27, so add all the needed libraries to .yaml file and to the INSTALL_APP.
I was using Django with Python 2.7 on Windows 7 and I installed XAMPP and used the PHPMyAdmin MySQL included with it to create a database to use in Django, but when I went and used the "python manage.py syncdb" command, I got this error:
Traceback (most recent call last):
File "iFriends\manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line 443, in execute_from
_command_line
utility.execute()
File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line 382, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line 261, in fetch_comman
d
klass = load_command_class(app_name, subcommand)
File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line 69, in load_command_
class
module = import_module('%s.management.commands.%s' % (app_name, name))
File "C:\Python27\lib\site-packages\django\utils\importlib.py", line 35, in import_module
__import__(name)
File "C:\Python27\lib\site-packages\django\core\management\commands\syncdb.py", line 8, in <module
>
from django.core.management.sql import custom_sql_for_model, emit_post_sync_signal
File "C:\Python27\lib\site-packages\django\core\management\sql.py", line 6, in <module>
from django.db import models
File "C:\Python27\lib\site-packages\django\db\__init__.py", line 40, in <module>
backend = load_backend(connection.settings_dict['ENGINE'])
File "C:\Python27\lib\site-packages\django\db\__init__.py", line 34, in __getattr__
return getattr(connections[DEFAULT_DB_ALIAS], item)
File "C:\Python27\lib\site-packages\django\db\utils.py", line 92, in __getitem__
backend = load_backend(db['ENGINE'])
File "C:\Python27\lib\site-packages\django\db\utils.py", line 24, in load_backend
return import_module('.base', backend_name)
File "C:\Python27\lib\site-packages\django\utils\importlib.py", line 35, in import_module
__import__(name)
File "C:\Python27\lib\site-packages\django\db\backends\mysql\base.py", line 16, in <module>
raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named MySQLdb
I have checked the host, username, password and those are correct, I really want to use Django so if anyone can help me on this, that would be great.
You need to install mysql lib for windows.
http://www.codegood.com/archives/4
http://www.lfd.uci.edu/~gohlke/pythonlibs/#mysql-python
http://www.codegood.com/archives/129
You require a dependency
easy_install mysql-python