I looked at the similar posts before entering this question. I am using Django 1.5, Python 3.3.2, and MySQL 5.6 / Connector.
I am new to Django/Python and working my way through basic tutorial. I created a MySQL database , sync a very simple model, and started basic web server.
I have added entries to the tables via the basic shell commands and everything worked fine.
However when I log into admin portal it immediately throws an exception.
The traceback I see on my browser when I successfully log into the admin portal is:
Environment:
Request Method: POST
Request URL: http://127.0.0.1:8000/admin/
Django Version: 1.6
Python Version: 3.3.2
Installed Applications:
('django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'webmgr')
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware')
Traceback:
File "C:\Python33\lib\site-packages\django\core\handlers\base.py" in get_response
114. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "C:\Python33\lib\site-packages\django\contrib\admin\sites.py" in wrapper
215. return self.admin_view(view, cacheable)(*args, **kwargs)
File "C:\Python33\lib\site-packages\django\utils\decorators.py" in _wrapped_view
99. response = view_func(request, *args, **kwargs)
File "C:\Python33\lib\site-packages\django\views\decorators\cache.py" in _wrapped_view_func
52. response = view_func(request, *args, **kwargs)
File "C:\Python33\lib\site-packages\django\contrib\admin\sites.py" in inner
197. return self.login(request)
File "C:\Python33\lib\site-packages\django\views\decorators\cache.py" in _wrapped_view_func
52. response = view_func(request, *args, **kwargs)
File "C:\Python33\lib\site-packages\django\contrib\admin\sites.py" in login
330. return login(request, **defaults)
File "C:\Python33\lib\site-packages\django\views\decorators\debug.py" in sensitive_post_parameters_wrapper
75. return view(request, *args, **kwargs)
File "C:\Python33\lib\site-packages\django\utils\decorators.py" in _wrapped_view
99. response = view_func(request, *args, **kwargs)
File "C:\Python33\lib\site-packages\django\views\decorators\cache.py" in _wrapped_view_func
52. response = view_func(request, *args, **kwargs)
File "C:\Python33\lib\site-packages\django\contrib\auth\views.py" in login
43. auth_login(request, form.get_user())
File "C:\Python33\lib\site-packages\django\contrib\auth\__init__.py" in login
83. request.session.cycle_key()
File "C:\Python33\lib\site-packages\django\contrib\sessions\backends\base.py" in cycle_key
277. self.create()
File "C:\Python33\lib\site-packages\django\contrib\sessions\backends\db.py" in create
40. self.save(must_create=True)
File "C:\Python33\lib\site-packages\django\contrib\sessions\backends\db.py" in save
63. obj.save(force_insert=must_create, using=using)
File "C:\Python33\lib\site-packages\django\db\transaction.py" in __exit__
298. connection.savepoint_commit(sid)
File "C:\Python33\lib\site-packages\django\db\backends\__init__.py" in savepoint_commit
249. self._savepoint_commit(sid)
File "C:\Python33\lib\site-packages\django\db\backends\__init__.py" in _savepoint_commit
203. self.cursor().execute(self.ops.savepoint_commit_sql(sid))
File "C:\Python33\lib\site-packages\django\db\backends\util.py" in execute
69. return super(CursorDebugWrapper, self).execute(sql, params)
File "C:\Python33\lib\site-packages\django\db\backends\util.py" in execute
53. return self.cursor.execute(sql, params)
File "C:\Python33\lib\site-packages\django\db\utils.py" in __exit__
86. db_exc_type = getattr(self.wrapper.Database, dj_exc_type.__name__)
Exception Type: AttributeError at /admin/
Exception Value: 'DatabaseWrapper' object has no attribute 'Database'
My settings file looks like:
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.6/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = ''
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
TEMPLATE_DEBUG = True
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'webmgr',
)
MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
)
ROOT_URLCONF = 'gymweb.urls'
WSGI_APPLICATION = 'gymweb.wsgi.application'
# Database
# https://docs.djangoproject.com/en/1.6/ref/settings/#databases
DATABASES = {
'default': {
'NAME': 'twntest',
'ENGINE': 'mysql.connector.django',
'USER': 'root',
'PASSWORD': '**********',
'OPTIONS': {
'autocommit': True,
},
}
}
"""
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
"""
# Internationalization
# https://docs.djangoproject.com/en/1.6/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.6/howto/static-files/
STATIC_URL = '/static/'
Reinstall django. Seems like you have installed django 1.5 on top of 1.4
Related
I am creating REST api, with Django Rest Framework, and first of all I have to give users the way to register. I saw django-rest-registration as easy way to make this, but when I did everything as is said in Quickstart, my terminal throws those errors:
django.core.management.base.SystemCheckError: SystemCheckError: System check identified some issues:
ERRORS:
?: (rest_registration.E001) RESET_PASSWORD_VERIFICATION_URL is not set
?: (rest_registration.E004) VERIFICATION_FROM_EMAIL is not set
System check identified 2 issues (0 silenced).
Here's my code:
settings.py:
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'rest_framework',
'corsheaders',
'rest_registration',
'app',
]
REST_REGISTRATION = {
'REGISTER_VERIFICATION_ENABLED': False,
'REGISTER_EMAIL_VERIFICATION_ENABLED': False,
'RESET_PASSWORD_VERIFICATION_ENABLED': False,
}
urlpatterns:
urlpatterns = [
path('admin/', admin.site.urls),
path('', include('app.urls')),
path('accounts/', include('rest_registration.api.urls')),
]
But, when I tried to change REST_REGISTRATION to this:
REST_REGISTRATION = {
'REGISTER_VERIFICATION_URL': 'https://frontend-host/verify-user/',
'RESET_PASSWORD_VERIFICATION_URL': 'https://frontend-host/reset-password/',
'REGISTER_EMAIL_VERIFICATION_URL': 'https://frontend-host/verify-email/',
'VERIFICATION_FROM_EMAIL': 'no-reply#example.com',
}
and I submitted the request, I saw another error:
ConnectionRefusedError at /accounts/register/
+ Traceback:
Environment:
Request Method: POST
Request URL: http://localhost:8000/accounts/register/
Django Version: 2.2.3
Python Version: 3.7.3
Installed Applications:
['django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'rest_framework',
'corsheaders',
'rest_registration',
'app']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'corsheaders.middleware.CorsMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware']
Traceback:
File "/home/fullnamedebian/.local/lib/python3.7/site-packages/django/core/handlers/exception.py" in inner
34. response = get_response(request)
File "/home/fullnamedebian/.local/lib/python3.7/site-packages/django/core/handlers/base.py" in _get_response
115. response = self.process_exception_by_middleware(e, request)
File "/home/fullnamedebian/.local/lib/python3.7/site-packages/django/core/handlers/base.py" in _get_response
113. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/fullnamedebian/.local/lib/python3.7/site-packages/django/views/decorators/csrf.py" in wrapped_view
54. return view_func(*args, **kwargs)
File "/home/fullnamedebian/.local/lib/python3.7/site-packages/django/views/generic/base.py" in view
71. return self.dispatch(request, *args, **kwargs)
File "/home/fullnamedebian/.local/lib/python3.7/site-packages/rest_framework/views.py" in dispatch
495. response = self.handle_exception(exc)
File "/home/fullnamedebian/.local/lib/python3.7/site-packages/rest_framework/views.py" in handle_exception
455. self.raise_uncaught_exception(exc)
File "/home/fullnamedebian/.local/lib/python3.7/site-packages/rest_framework/views.py" in dispatch
492. response = handler(request, *args, **kwargs)
File "/home/fullnamedebian/.local/lib/python3.7/site-packages/rest_framework/decorators.py" in handler
55. return func(*args, **kwargs)
File "/home/fullnamedebian/.local/lib/python3.7/site-packages/rest_registration/api/views/register.py" in register
96. send_verification_notification(user, signer, template_config)
File "/home/fullnamedebian/.local/lib/python3.7/site-packages/rest_registration/notifications/email.py" in send_verification_notification
24. send_notification(notification)
File "/home/fullnamedebian/.local/lib/python3.7/site-packages/rest_registration/notifications/email.py" in send_notification
209. notification.send()
File "/home/fullnamedebian/.local/lib/python3.7/site-packages/django/core/mail/message.py" in send
291. return self.get_connection(fail_silently).send_messages([self])
File "/home/fullnamedebian/.local/lib/python3.7/site-packages/django/core/mail/backends/smtp.py" in send_messages
103. new_conn_created = self.open()
File "/home/fullnamedebian/.local/lib/python3.7/site-packages/django/core/mail/backends/smtp.py" in open
63. self.connection = self.connection_class(self.host, self.port, **connection_params)
File "/usr/lib/python3.7/smtplib.py" in __init__
251. (code, msg) = self.connect(host, port)
File "/usr/lib/python3.7/smtplib.py" in connect
336. self.sock = self._get_socket(host, port, self.timeout)
File "/usr/lib/python3.7/smtplib.py" in _get_socket
307. self.source_address)
File "/usr/lib/python3.7/socket.py" in create_connection
727. raise err
File "/usr/lib/python3.7/socket.py" in create_connection
716. sock.connect(sa)
Exception Type: ConnectionRefusedError at /accounts/register/
Exception Value: [Errno 111] Connection refused
I added email settings:
# Email settings
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'localhost'
EMAIL_PORT = 8000
And now when I submit post I just see this in terminal: [22/Sep/2019 14:44:54] "POST /accounts/register/ HTTP/1.1" 400 13646 (Its drawn with red font, if it matters). And webpage is loading infinitley.
I have this error for 2 days now I triyed everything in the other topics nothings works for me. The code of the app was written in linux, but i got the folder and connected it to my project as an app, in this project there is 3 apps that are connecting good to the database, only this one gives an error unable to open data base. I'm using Windows on Localhost, a friend triyed on windows and it's working for him, only for me not working.
Note : When I go to localhost:8000/admin I can see the model created on the database.
PLEASE HELP!
Django Version: 2.2.3
I have tryied to give permissions of the folder on it's proprieties to read and write, tryied to change path of DIR, I switched from sqlite3 to postgres, made full path in database and not full one, triyed all the recommandations on topics but still shows the error
Settings. py
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'devee',
'USER': 'postgres',
'PASSWORD': 'thepasswordichoosed',
'HOST': 'localhost',
'PORT': '5432',
}
}
Environment:
Request Method: POST
Request URL: http://localhost:8000/result
Django Version: 2.2.3
Python Version: 3.7.3
Installed Applications:
['django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'dashboard',
'account',
'analyse']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware']
Traceback:
File "C:\Users\I500913\AppData\Local\Continuum\anaconda3\lib\site-packages\django\core\handlers\exception.py" in inner
34. response = get_response(request)
File "C:\Users\I500913\AppData\Local\Continuum\anaconda3\lib\site-packages\django\core\handlers\base.py" in _get_response
115. response = self.process_exception_by_middleware(e, request)
File "C:\Users\I500913\AppData\Local\Continuum\anaconda3\lib\site-packages\django\core\handlers\base.py" in _get_response
113. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "C:\Users\I500913\AppData\Local\Continuum\anaconda3\lib\site-packages\django\views\decorators\csrf.py" in wrapped_view
54. return view_func(*args, **kwargs)
File "C:\Users\I500913\Desktop\Projets\final\analyse\views.py" in analyse_result
22. seo_score, report = scrapper(website)
File "C:\Users\I500913\Desktop\Projets\final\analyse\seo_scrapper.py" in scrapper
411. sbl = SafeBrowsingList(api_key)
File "C:\Users\I500913\AppData\Local\Continuum\anaconda3\lib\site-packages\gglsbl\client.py" in __init__
35. self.storage = SqliteStorage(db_path, timeout=timeout)
File "C:\Users\I500913\AppData\Local\Continuum\anaconda3\lib\site-packages\gglsbl\storage.py" in __init__
73. self.db = sqlite3.connect(db_path, timeout)
Exception Type: OperationalError at /result
Exception Value: unable to open database file
I am new to Django, and I just took over from another developer on this project. All I have done so far is clone the code from git and install the dependencies.
Immediately after setting up the project, and running python manager.py runserver and going to localhost:8000/admin I get an error stating the TypeError at /admin/login/, 'CsrfViewMiddleware' object is not iterable:
Traceback:
File
"/home/abhay/code/virtualenvironments/leaguesx/lib/python3.5/site-packages/django/core/handlers/exception.py"
in inner
39. response = get_response(request)
File
"/home/abhay/code/virtualenvironments/leaguesx/lib/python3.5/site-packages/django/core/handlers/base.py"
in _legacy_get_response
249. response = self._get_response(request)
File
"/home/abhay/code/virtualenvironments/leaguesx/lib/python3.5/site-packages/django/core/handlers/base.py"
in _get_response
217. response = self.process_exception_by_middleware(e, request)
File
"/home/abhay/code/virtualenvironments/leaguesx/lib/python3.5/site-packages/django/core/handlers/base.py"
in _get_response
215. response = response.render()
File
"/home/abhay/code/virtualenvironments/leaguesx/lib/python3.5/site-packages/django/template/response.py"
in render
109. self.content = self.rendered_content
File
"/home/abhay/code/virtualenvironments/leaguesx/lib/python3.5/site-packages/django/template/response.py"
in rendered_content
86. content = template.render(context, self._request)
File
"/home/abhay/code/virtualenvironments/leaguesx/lib/python3.5/site-packages/django/template/backends/django.py"
in render
66. return self.template.render(context)
File
"/home/abhay/code/virtualenvironments/leaguesx/lib/python3.5/site-packages/django/template/base.py"
in render
206. with context.bind_template(self):
File "/usr/lib/python3.5/contextlib.py" in __enter__
59. return next(self.gen)
File
"/home/abhay/code/virtualenvironments/leaguesx/lib/python3.5/site-packages/django/template/context.py"
in bind_template
236. updates.update(processor(self.request))
Exception Type: TypeError at /admin/login/
Exception Value: 'CsrfViewMiddleware' object is not iterable
I would post code from the source code but I can't figure where in the source the cause of this might possibly be.
My settings.py:
import os
from datetime import datetime
from django.conf.global_settings import EMAIL_USE_SSL
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'rest_framework',
'ourapp',
'social.apps.django_app.default',
'sendgrid',
'corsheaders',
)
MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
# 'django.middleware.clickjacking.XFrameOptionsMiddleware',
'ourapp.middleWare.authenticationMiddleware.AuthenticationMiddleware'
)
ROOT_URLCONF = ''
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.contrib.auth.context_processors.auth',
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
'django.middleware.csrf.CsrfViewMiddleware',
'corsheaders.middleware.CorsMiddleware',
'social.apps.django_app.context_processors.backends',
'social.apps.django_app.context_processors.login_redirect',
],
},
},
]
(Sorry about the lack of indentation.)
Any ideas on how to proceed from here would be greatly appreciated!
Try removing 'django.middleware.csrf.CsrfViewMiddleware', from TEMPLATES. Probably 'corsheaders.middleware.CorsMiddleware', too
Inside a Django project, I have one app, otherapp, which hits a Postgres database on a remote server that contains scraped data. I have a second app, content, which hits a different Postgres database on the same remote server, and contains pages I'd like to have served through the Wagtail CMS.
I installed Wagtail locally using these instructions (I did not use the Wagtail installer). I got it working locally. Then, I did a pg_dump of the local database and did psql db2 < db2dumpfile.sql on the remote database server.
Each of the apps works fine locally in isolation, but I can't get them to work together. I thought I could use a database router to specify which database I want used to retrieve different types of data.
But, when I put the database router into the settings file, it starts to fail. How can I fix this? Do I need to declare wagtailcore somewhere else in the project?
settings.py:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'db1',
'USER': DB_USERNAME,
'PASSWORD': DB_PASSWORD,
'HOST': HOST,
'PORT': PORT
},
'CMS': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'db2',
'USER': DB_USERNAME,
'PASSWORD': DB_PASSWORD,
'HOST': HOST,
'PORT': PORT
}
}
DATABASE_ROUTERS = [ 'projectname.routers.FindRouter',]
routers.py:
import os
from django.conf import settings
import socket
class FindRouter(object):
def db_for_read(self, model, **hints) :
if model._meta.app_label == 'content' :
return 'CMS'
return None
def db_for_read(self, model, **hints):
if model._meta.app_label == 'content' :
return 'CMS'
return None
def db_for_write(self, model, **hints):
if model._meta.app_label == 'content' :
return 'CMS'
return None
def allow_relation(self, obj1, obj2, **hints):
if obj1._meta.app_label == 'content' or obj2._meta.app_label == 'content':
return True
return None
def allow_migrate(self, db, app_label, model=None, **hints):
if app_label == 'content' :
return db == 'CMS'
return None
This is the error I am getting when I do runserver:
Environment:
Request Method: GET
Request URL: http://127.0.0.1:8000/cms/
Django Version: 1.9
Python Version: 2.7.10
Installed Applications:
['django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'wagtail.wagtailforms',
'wagtail.wagtailredirects',
'wagtail.wagtailembeds',
'wagtail.wagtailsites',
'wagtail.wagtailusers',
'wagtail.wagtailsnippets',
'wagtail.wagtaildocs',
'wagtail.wagtailimages',
'wagtail.wagtailsearch',
'wagtail.wagtailadmin',
'wagtail.wagtailcore',
'modelcluster',
'compressor',
'taggit',
'otherapp',
'content']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.security.SecurityMiddleware',
'wagtail.wagtailcore.middleware.SiteMiddleware',
'wagtail.wagtailredirects.middleware.RedirectMiddleware']
Traceback:
File "/Users/username/.virtualenvs/bail/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
123. response = middleware_method(request)
File "/Users/username/.virtualenvs/bail/lib/python2.7/site-packages/wagtail/wagtailcore/middleware.py" in process_request
11. request.site = Site.find_for_request(request)
File "/Users/username/.virtualenvs/bail/lib/python2.7/site-packages/wagtail/wagtailcore/models.py" in find_for_request
122. return Site.objects.get(hostname=hostname) # Site.DoesNotExist here goes to the final except clause
File "/Users/username/.virtualenvs/bail/lib/python2.7/site-packages/django/db/models/manager.py" in manager_method
122. return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/Users/username/.virtualenvs/bail/lib/python2.7/site-packages/django/db/models/query.py" in get
381. num = len(clone)
File "/Users/username/.virtualenvs/bail/lib/python2.7/site-packages/django/db/models/query.py" in __len__
240. self._fetch_all()
File "/Users/username/.virtualenvs/bail/lib/python2.7/site-packages/django/db/models/query.py" in _fetch_all
1074. self._result_cache = list(self.iterator())
File "/Users/username/.virtualenvs/bail/lib/python2.7/site-packages/django/db/models/query.py" in __iter__
52. results = compiler.execute_sql()
File "/Users/username/.virtualenvs/bail/lib/python2.7/site-packages/django/db/models/sql/compiler.py" in execute_sql
852. cursor.execute(sql, params)
File "/Users/username/.virtualenvs/bail/lib/python2.7/site-packages/django/db/backends/utils.py" in execute
79. return super(CursorDebugWrapper, self).execute(sql, params)
File "/Users/username/.virtualenvs/bail/lib/python2.7/site-packages/django/db/backends/utils.py" in execute
64. return self.cursor.execute(sql, params)
File "/Users/username/.virtualenvs/bail/lib/python2.7/site-packages/django/db/utils.py" in __exit__
95. six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/Users/username/.virtualenvs/bail/lib/python2.7/site-packages/django/db/backends/utils.py" in execute
64. return self.cursor.execute(sql, params)
Exception Type: ProgrammingError at /cms/
Exception Value: relation "wagtailcore_site" does not exist
LINE 1: ...ge_id", "wagtailcore_site"."is_default_site" FROM "wagtailco...
^
I gave up and put the Wagtail tables back into the first database, and now the two parts of the application are working together fine.
This is what I am trying to run. When I run the server and run these lines within a view and then return an HttpResponse, then everything goes fine. However when I run python manage.py shell and then try to run through these lines then I get an error:
product = Product.objects.get(pk=4)
template = loader.get_template('weekly-email.html')
user = User.objects.get(pk=1)
body = template.render(Context({
'user': user,
'product': product,
}))
Output:
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/Users/croberts/.virtualenvs/testproj/lib/python3.4/site-packages/django/template/backends/django.py", line 74, in render
return self.template.render(context)
File "/Users/croberts/.virtualenvs/testproj/lib/python3.4/site-packages/django/template/base.py", line 209, in render
return self._render(context)
File "/Users/croberts/.virtualenvs/testproj/lib/python3.4/site-packages/django/template/base.py", line 201, in _render
return self.nodelist.render(context)
File "/Users/croberts/.virtualenvs/testproj/lib/python3.4/site-packages/django/template/base.py", line 903, in render
bit = self.render_node(node, context)
File "/Users/croberts/.virtualenvs/testproj/lib/python3.4/site-packages/django/template/base.py", line 917, in render_node
return node.render(context)
File "/Users/croberts/.virtualenvs/testproj/lib/python3.4/site-packages/django/template/base.py", line 963, in render
return render_value_in_context(output, context)
File "/Users/croberts/.virtualenvs/testproj/lib/python3.4/site-packages/django/template/base.py", line 939, in render_value_in_context
value = localize(value, use_l10n=context.use_l10n)
File "/Users/croberts/.virtualenvs/testproj/lib/python3.4/site-packages/django/utils/formats.py", line 181, in localize
return number_format(value, use_l10n=use_l10n)
File "/Users/croberts/.virtualenvs/testproj/lib/python3.4/site-packages/django/utils/formats.py", line 162, in number_format
get_format('DECIMAL_SEPARATOR', lang, use_l10n=use_l10n),
File "/Users/croberts/.virtualenvs/testproj/lib/python3.4/site-packages/django/utils/formats.py", line 110, in get_format
for module in get_format_modules(lang):
File "/Users/croberts/.virtualenvs/testproj/lib/python3.4/site-packages/django/utils/formats.py", line 82, in get_format_modules
modules = _format_modules_cache.setdefault(lang, list(iter_format_modules(lang, settings.FORMAT_MODULE_PATH)))
File "/Users/croberts/.virtualenvs/testproj/lib/python3.4/site-packages/django/utils/formats.py", line 51, in iter_format_modules
if not check_for_language(lang):
File "/Users/croberts/.virtualenvs/testproj/lib/python3.4/site-packages/django/utils/translation/__init__.py", line 181, in check_for_language
return _trans.check_for_language(lang_code)
File "/Users/croberts/.virtualenvs/testproj/lib/python3.4/functools.py", line 472, in wrapper
result = user_function(*args, **kwds)
File "/Users/croberts/.virtualenvs/testproj/lib/python3.4/site-packages/django/utils/translation/trans_real.py", line 409, in check_for_language
if not language_code_re.search(lang_code):
TypeError: expected string or buffer
edit: and here is my settings.py:
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os
DEBUG = True
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
SECRET_KEY = 'SECRET'
ALLOWED_HOSTS = []
AUTH_USER_MODEL = 'crunch.User'
STATICFILES_DIRS = (
'/Users/croberts/testproj/static/',
)
# Application definition
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'crunch',
'emailmanager',
)
MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.security.SecurityMiddleware',
)
ROOT_URLCONF = 'testproj.urls'
WSGI_APPLICATION = 'testproj.wsgi.application'
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'database'),
}
}
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'MST'
USE_I18N = True
USE_L10N = True
USE_TZ = False
STATIC_URL = '/static/'
MEDIA_ROOT = BASE_DIR+'/media/'
MEDIA_URL = '/media/'
Also, I am using django 1.8.
This is a known issue and will be fixed in 1.8.1.
Meanwhile, you can manually activate a language in your shell to fix it:
from django.utils.translation import activate
activate('en') # or any language code
UPDATE: 1.8.1 has been released, so the best solution is to upgrade to the latest 1.8.x version.