Django error: VariableDoesNotExist: Failed lookup for key [request] in u'[{}]'
Can anybody explain to me how to deal with the error as in the question title?
Can anybody explain to me how to deal with the error as in the question title?
This could be caused by several things:
python manage.py syncdb
and python manage.py migrate
'django.core.context_processors.request',
in the TEMPLATE_CONTEXT_PROCESSORS
urls.py
- in the django project root.Askbot provides a sample urls.py
in the directory askbot/setup_templates
, you can take it there, or run askbot-setup
. askbot-setup
will make a copy, but will not overwrite an existing file though.
How was this issue solved? I'm having the exact same issue here.
In my case I skipped past the super user creation step and apparently askbot doesn't like this.
Nope, it is not a problem normally. How did you create the settings.py
and urls.py
files for your project?
I had the same problem here, it "went away" mysteriously.
the urls.py is there, but the error still exists. I am using the source from github to deploy on a ubuntu server.
I saw this error when urls.py
file was there but did not have all the urls for askbot defined. Also it is possible that root url conf setting in your settings.py
. Compare your urls.py
with askbot/setup_templates/urls.py
.
i used askbot-setup for the project, and urls.py remains the same, root url conf is here> ROOT_URLCONF = os.path.basename(os.path.dirname(file)) + '.urls'
ROOT_URLCONF = os.path.basename(os.path.dirname(file)) + '.urls'
Could you send me your settings.py? Did you modify other files?
Yes, I solved my problem :-) Thanks to Evgeny.
This is my settings.py:
#!/usr/bin/env python26
# Django settings for myproject project.
#ASKBOT
import os.path
import logging
import sys
import askbot
import os
DEBUG = False
TEMPLATE_DEBUG = DEBUG
ADMINS = (
# ('Your Name', 'your_email@example.com'),
)
MANAGERS = ADMINS
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
'NAME': '*************', # Or path to database file if using sqlite3.
'USER': '*************', # Not used with sqlite3.
'PASSWORD': '*************', # Not used with sqlite3.
'HOST': '*************', # Set to empty string for localhost. Not used with sqlite3.
'PORT': '', # Set to empty string for default. Not used with sqlite3.
}
}
#ASKBOT
#outgoing mail server settings
SERVER_EMAIL = '************'
DEFAULT_FROM_EMAIL = '************'
EMAIL_HOST_USER = '************'
EMAIL_HOST_PASSWORD = ''
EMAIL_SUBJECT_PREFIX = ''
EMAIL_HOST=''
EMAIL_PORT=''
EMAIL_USE_TLS=False
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
IMAP_HOST = ''
IMAP_HOST_USER = ''
IMAP_HOST_PASSWORD = ''
IMAP_PORT = ''
IMAP_USE_TLS = False
# Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
# although not all choices may be available on all operating systems.
# On Unix systems, a value of None will cause Django to use the same
# timezone as the operating system.
# If running in a Windows environment this must be set to the same as your
# system time zone.
TIME_ZONE = 'America/Chicago'
# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE = 'en'
SITE_ID = 1
# If you set this to False, Django will make some optimizations so as not
# to load the internationalization machinery.
USE_I18N = True
# If you set this to False, Django will not format dates, numbers and
# calendars according to the current locale
USE_L10N = True
# Absolute filesystem path to the directory that will hold user-uploaded files.
# Example: "/home/media/media.lawrence.com/media/"
MEDIA_ROOT = '/home/webapp/webapps/media/'
# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash.
# Examples: "http://media.lawrence.com/media/", "http://example.com/media/"
MEDIA_URL = 'http://webapp.webfactional.com/media/'
# Absolute path to the directory static files should be collected to.
# Don't put anything in this directory yourself; store your static files
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
# Example: "/home/media/media.lawrence.com/static/"
STATIC_ROOT = ''
# URL prefix for static files.
# Example: "http://media.lawrence.com/static/"
STATIC_URL = '/static/'
# URL prefix for admin static files -- CSS, JavaScript and images.
# Make sure to use a trailing slash.
# Examples: "http://foo.com/static/admin/", "/static/admin/".
ADMIN_MEDIA_PREFIX = 'http://webapp.webfactional.com/media/admin/'
#ASKBOT
#this line is added so that we can import pre-packaged askbot dependencies
sys.path.append(os.path.join(os.path.dirname(askbot.__file__), 'deps'))
PROJECT_ROOT = os.path.join(os.path.dirname(__file__), 'forum')
ASKBOT_FILE_UPLOAD_DIR = os.path.join(os.path.dirname(__file__), 'forum', 'askbot', 'upfiles')
# Additional locations of static files
STATICFILES_DIRS = (
# Put strings here, like "/home/html/static" or "C:/www/django/static".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
)
# List of finder classes that know how to find static files in
# various locations.
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
'django.contrib.staticfiles.finders.DefaultStorageFinder',
)
# Make ...
(more)Fabio, I took these settings and was able to make the forum work. What do you do to make it fail - access some specific url?
Hi Evgeny, I simply try to access to root url or to /admin location.
Can't reproduce. Can you email me a zipped version of your project directory? My email is evgeny.fadeev@gmail.com. Is settings.py the only difference from stock askbot in your project?
It is possible that there is some bug, but in this case to figure this out I need to see entire project. One thing I notice in your settings - CSRF_COOKIE_DOMAIN
is not set, but it is unlikely to be the source of this particular error.
I have installed askbot on webfaction server as a reusable django application, but I have gott this error:
[Sun Sep 25 23:51:40 2011] [notice] Apache/2.2.17 (Unix) mod_wsgi/3.3 Python/2.7.1 configured -- resuming normal operations
[Sun Sep 25 16:51:44 2011] [error] /home/webapp/lib/python2.6/coffin/common.py:49: UserWarning: Cannot translate loader: askbot.skins.loaders.load_template_source
[Sun Sep 25 16:51:44 2011] [error] warnings.warn('Cannot translate loader: %s' % loader)
[Sun Sep 25 16:51:44 2011] [error] [client 127.0.0.1] mod_wsgi (pid=9004): Exception occurred processing WSGI script '/home/webapp/webapps/django/myproject.wsgi'.
[Sun Sep 25 16:51:44 2011] [error] [client 127.0.0.1] Traceback (most recent call last):
[Sun Sep 25 16:51:44 2011] [error] [client 127.0.0.1] File "/home/webapp/lib/python2.6/django/core/handlers/wsgi.py", line 272, in __call__
[Sun Sep 25 16:51:44 2011] [error] [client 127.0.0.1] response = self.get_response(request)
[Sun Sep 25 16:51:44 2011] [error] [client 127.0.0.1] File "/home/webapp/lib/python2.6/django/core/handlers/base.py", line 153, in get_response
[Sun Sep 25 16:51:44 2011] [error] [client 127.0.0.1] response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
[Sun Sep 25 16:51:44 2011] [error] [client 127.0.0.1] File "/home/webapp/lib/python2.6/django/core/handlers/base.py", line 218, in handle_uncaught_exception
[Sun Sep 25 16:51:44 2011] [error] [client 127.0.0.1] return callback(request, **param_dict)
[Sun Sep 25 16:51:44 2011] [error] [client 127.0.0.1] File "/home/webapp/lib/python2.6/django/utils/decorators.py", line 93, in _wrapped_view
[Sun Sep 25 16:51:44 2011] [error] [client 127.0.0.1] response = view_func(request, *args, **kwargs)
[Sun Sep 25 16:51:44 2011] [error] [client 127.0.0.1] File "/home/webapp/lib/python2.6/django/views/defaults.py", line 31, in server_error
[Sun Sep 25 16:51:44 2011] [error] [client 127.0.0.1] return http.HttpResponseServerError(t.render(Context({})))
[Sun Sep 25 16:51:44 2011] [error] [client 127.0.0.1] File "/home/webapp/lib/python2.6/django/template/base.py", line 123, in render
[Sun Sep 25 16:51:44 2011] [error] [client 127.0.0.1] return self._render(context)
[Sun Sep 25 16:51:44 2011] [error] [client 127.0.0.1] File "/home/webapp/lib/python2.6/django/template/base.py", line 117, in _render
[Sun Sep 25 16:51:44 2011] [error] [client 127.0.0.1] return self.nodelist.render(context)
[Sun Sep 25 16:51:44 2011] [error] [client 127.0.0.1] File "/home/webapp/lib/python2.6/django/template/base.py", line 744, in render
[Sun Sep 25 16:51:44 2011] [error] [client 127.0.0.1] bits.append(self.render_node(node, context))
[Sun Sep 25 16:51:44 2011] [error] [client ...
(more)Fabio, can you paste your settings.py
somewhere (after deleting passwords). Did you use askbot-setup
script? I think you might be missing something in the TEMPLATE_CONTEXT_PROCESSORS
variable of the settings. The template of settings.py
used by askbot is in askbot/setup_templates/settings.py
.
The askbot-setup
script creates settings.py
in your project directory, based on the template, but if you already have a settings.py
your file will not be updated automatically - in that case it will be necessary to add the changes to the settings file manually.
Hi Evgeny, I did as you tell, but I continue to have the same error.
Hi Fitoria, I check the path of TEMPLATE_DIR, but it seems correct.
Maybe this log can help you to find the solution:
[Tue Sep 27 16:02:36 2011] [error] /home/webapp/lib/python2.6/coffin/common.py:49: UserWarning: Cannot translate loader: askbot.skins.loaders.load_template_source
[Tue Sep 27 16:02:36 2011] [error] warnings.warn('Cannot translate loader: %s' % loader)
[Tue Sep 27 16:02:36 2011] [error] <WSGIRequest
[Tue Sep 27 16:02:36 2011] [error] GET:<QueryDict: {}>,
[Tue Sep 27 16:02:36 2011] [error] POST:<QueryDict: {}>,
[Tue Sep 27 16:02:36 2011] [error] COOKIES:{'sessionid': 'ac06b15de9368da994923c9202971198'},
[Tue Sep 27 16:02:36 2011] [error] META:{'DOCUMENT_ROOT': '/usr/local/apache2/htdocs',
[Tue Sep 27 16:02:36 2011] [error] 'GATEWAY_INTERFACE': 'CGI/1.1',
[Tue Sep 27 16:02:36 2011] [error] 'HTTP_ACCEPT': '*/*',
[Tue Sep 27 16:02:36 2011] [error] 'HTTP_ACCEPT_CHARSET': 'ISO-8859-1,utf-8;q=0.7,*;q=0.3',
[Tue Sep 27 16:02:36 2011] [error] 'HTTP_ACCEPT_ENCODING': 'gzip,deflate,sdch',
[Tue Sep 27 16:02:36 2011] [error] 'HTTP_ACCEPT_LANGUAGE': 'it-IT,it;q=0.8,en-US;q=0.6,en;q=0.4',
[Tue Sep 27 16:02:36 2011] [error] 'HTTP_CONNECTION': 'close',
[Tue Sep 27 16:02:36 2011] [error] 'HTTP_COOKIE': 'sessionid=ac06b15de9368da994923c9202971198',
[Tue Sep 27 16:02:36 2011] [error] 'HTTP_HOST': 'webapp.webfactional.com',
[Tue Sep 27 16:02:36 2011] [error] 'HTTP_USER_AGENT': 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/14.0.835.186 Safari/535.1',
[Tue Sep 27 16:02:36 2011] [error] 'HTTP_X_FORWARDED_FOR': '2.225.106.8',
[Tue Sep 27 16:02:36 2011] [error] 'HTTP_X_FORWARDED_HOST': 'webapp.webfactional.com',
[Tue Sep 27 16:02:36 2011] [error] 'HTTP_X_FORWARDED_SERVER': 'webapp.webfactional.com',
[Tue Sep 27 16:02:36 2011] [error] 'PATH_INFO': u'/favicon.ico',
[Tue Sep 27 16:02:36 2011] [error] 'PATH_TRANSLATED': '/home/webapp/webapps/django/myproject.wsgi/favicon.ico',
[Tue Sep 27 16:02:36 2011] [error] 'QUERY_STRING': '',
[Tue Sep 27 16:02:36 2011] [error] 'REMOTE_ADDR': '127.0.0.1',
[Tue Sep 27 16:02:36 2011] [error] 'REMOTE_PORT': '46926',
[Tue Sep 27 16:02:36 2011] [error] 'REQUEST_METHOD': 'GET',
[Tue Sep 27 16:02:36 2011] [error] 'REQUEST_URI': '/favicon.ico',
[Tue Sep 27 16:02:36 2011] [error] 'SCRIPT_FILENAME': '/home/webapp/webapps/django/myproject.wsgi',
[Tue Sep 27 16:02:36 2011] [error] 'SCRIPT_NAME': u'',
[Tue Sep 27 16:02:36 2011] [error] 'SERVER_ADDR': '127.0.0.1',
[Tue Sep 27 16:02:36 2011] [error] 'SERVER_ADMIN': '[no address given]',
[Tue Sep 27 16:02:36 2011] [error] 'SERVER_NAME': 'webapp.webfactional.com',
[Tue Sep 27 16:02:36 2011] [error] 'SERVER_PORT': '80',
[Tue Sep 27 16:02:36 2011] [error] 'SERVER_PROTOCOL': 'HTTP/1.0',
[Tue Sep 27 16:02:36 2011] [error] 'SERVER_SIGNATURE': '',
[Tue Sep 27 16:02:36 2011] [error] 'SERVER_SOFTWARE': 'Apache/2.2.17 (Unix) mod_wsgi/3.3 Python/2.7.1',
[Tue Sep 27 16:02:36 2011] [error] 'mod_wsgi.application_group': 'web223.webfaction.com|',
[Tue Sep 27 ...
(more)Hello. I am having the exact same problem and I dont understand what is the solution.
@Evgeny Regarding your proposals: I have run syncdb, migrate and I got all my configurations from askbot/setup_templates.
Something that may help more is that I have the exact same configuration files (except the name of the database and password) both in my local environment and in my server. In my local environment I dont have any problems. Problem appears only in the other environment.
I dont know if also helps but I also skipped the step about setting up a super user. I know that you already said that this should not affect but I want to add this info also. I followed all the steps that my provider suggested me about setting up a django application (actually it was a matter of few clicks, everything set up automatically). By the way, these are the versions I use Django 1.3.1 (mod_wsgi 3.2/Python 2.6)
Thanx in advance
Did migrate
command work for you? Which database are you using?
Postresql 9.1.0. About migrate command, your suspicions may be right. I am having these logs:
python2.6/django/db/__init__.py:19: DeprecationWarning: settings.DATABASE_* is deprecated; use settings.DATABASES instead. DeprecationWarning python2.6/django/db/__init__.py:60: DeprecationWarning: Short names for ENGINE in database configurations are deprecated. Prepend default.ENGINE with 'django.db.backends.' DeprecationWarning Running migrations for django_authopenid: - Nothing to migrate - Loading initial data for django_authopenid. No fixtures found. Running migrations for askbo
Askbot migrations have issues with Postgres 9.1, please see solution here http://askbot.org/en/question/7029/finally-got-askbot-working-on-webfactional and the link within (more importantly). Don't forget to set up full text search with the command, mentioned in the webfactional support forum.
Thanx. I will read the instructions. If problem is fixed, I will let you know. Thanx again
migrate command didn't work for me i'm using mysql
To enter a block of code:
Comments
I will try to answer tomorrow, but basically - just like any other django app. Askbot does not require anything special (aside from the stuff in the docs). Please look up "how to install django app" on that host.
rephrased the question as it had nothing to do with the hosting provider.