Restoring db in odoo 14 - python

Facing an error in Odoo 14 during the restoring process and also while running the server on the terminal.
Surprisingly it can run on the web, just can't proceed with the login with an error when doing the same.
Traceback (most recent call last):
File "/home/me/usr/oishi_odoo14/addons/web/controllers/main.py", line 946, in web_login
uid = request.session.authenticate(request.session.db, request.params['login'], request.params['password'])
File "/home/me/usr/oishi_odoo14/odoo/http.py", line 1025, in authenticate
uid = odoo.registry(db)['res.users'].authenticate(db, login, password, env)
File "/home/me/usr/oishi_odoo14/addons/website/models/res_users.py", line 70, in authenticate
uid = super(ResUsers, cls).authenticate(db, login, password, user_agent_env)
File "/home/me/usr/oishi_odoo14/odoo/addons/base/models/res_users.py", line 713, in authenticate
uid = cls._login(db, login, password, user_agent_env=user_agent_env)
doo14/odoo/sql_db.py", line 101, in check
return f(self, *args, **kwargs)
File "/home/me/usr/oishi_odoo14/odoo/sql_db.py", line 300, in execute
res = self._obj.execute(query, params)
Exception
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/me/usr/oishi_odoo14/odoo/addons/base/models/ir_http.py", line 237, in _dispatch
result = request.dispatch()
File "/home/me/usr/oishi_odoo14/odoo/http.py", line 806, in dispatch
r = self._call_function(**self.params)
File "/home/me/usr/oishi_odoo14/odoo/http.py", line 359, in _call_function
return checked_call(self.db, *args, **kwargs)
File "/home/me/usr/oishi_odoo14/odoo/service/model.py", line 94, in wrapper
return f(dbname, *args, **kwargs)
File "/home/me/usr/oishi_odoo14/odoo/http.py", line 347, in checked_call
result = self.endpoint(*a, **kw)
File "/home/me/usr/oishi_odoo14/addons/website/controllers/main.py", line 140, in web_login
return super().web_login(*args, **kw)
File "/home/me/usr/oishi_odoo14/addons/web/controllers/main.py", line 946, in web_login
uid = request.session.authenticate(request.session.db, request.params['login'], request.params['password'])
File "/home/me/usr/oishi_odoo14/odoo/http.py", line 1025, in authenticate
uid = odoo.registry(db)['res.users'].authenticate(db, login, password, env)
File "/home/me/usr/oishi_odoo14/addons/website/models/res_users.py", line 70, in authenticate
uid = super(ResUsers, cls).authenticate(db, login, password, user_agent_env)
File "/home/me/usr/oishi_odoo14/odoo/addons/base/models/res_users.py", line 713, in authenticate
uid = cls._login(db, login, password, user_agent_env=user_agent_env)
File "/home/me/usr/oishi_odoo14/odoo/addons/base/models/res_users.py", line 690, in _login
if tz in pytz.all_timezones and (not user.tz or not user.login_date):
File "/home/me/usr/oishi_odoo14/odoo/fields.py", line 1021, in __get__
self.compute_value(recs)
File "/home/me/usr/oishi_odoo14/odoo/fields.py", line 555, in _compute_related
record[self.name] = self._process_related(value[self.related_field.name])
File "/home/me/usr/oishi_odoo14/odoo/models.py", line 5694, in __getitem__
return self._fields[key].__get__(self, type(self))
File "/home/me/usr/oishi_odoo14/odoo/models.py", line 3071, in _fetch_field
self._read(fnames)
File "/home/me/usr/oishi_odoo14/odoo/models.py", line 3138, in _read
cr.execute(query_str, params + [sub_ids])
File "<decorator-gen-3>", line 2, in execute
File "/home/me/usr/oishi_odoo14/odoo/sql_db.py", line 101, in check
return f(self, *args, **kwargs)
File "/home/me/usr/oishi_odoo14/odoo/sql_db.py", line 300, in execute
res = self._obj.execute(query, params)
psycopg2.errors.UndefinedColumn: column res_partner.gender does not exist
LINE 1: ..."res_partner"."company_size2" as "company_size2", "res_partn...
^
HINT: Perhaps you meant to reference the column "res_partner.index".
I've tried various solutions on web with the error specified, but still couldn't resolve the error.
Anyone experienced a similar issues?, if do then
how come you resolved the issue?
Thanks

First approach for this issue is: to re-create the custom-field: (example: "res_partner.gender") in your custom module, in the corresponding model which _inherit=res_partner...
Another approach:
I had a similar problem, because i had delete a custom-field from a model, but this field was still used in a view.
I could solve it by desactivating the concerned view(s) containing my custom field (website.mycustomfield) using p.SQL request:
To identify the concerned views:
SELECT public.ir_ui_view
WHERE arch_db like '%website.mycustomfield%'
To desactivate the concerned views:
UPDATE public.ir_ui_view
SET active = false
WHERE arch_db like '%website.mycustomfield%'
Other insights into this issue:
https://www.youtube.com/watch?v=-zXnlycSXog
https://www.odoo.com/fr_FR/forum/aide-1/undefined-column-in-employees-module-182628
Can't install own custom modules in Odoo 13
PostgreSQL: column does not exists
problem odoo 13 and odoo12 not work but odoo11 working

Related

Can't install own custom modules in Odoo 13

During the last two days I have been trying to install a custom module in Odoo 13. I got the same error over and over again, telling that a column didn't exist in the model that I was creating (the variable in the class did, indeed, exist), I show the error down below.
The python code of the module is the following:
from odoo import models, fields, api
class OfferStage(models.Model):
_name = 'offer.stage'
_description = 'Offer stage'
name = fields.Char()
revisable = fields.Boolean()
sequence = fields.Integer()
modificable = fields.Boolean()
notify_jefe = fields.Boolean()
fold = fields.Boolean()
convertible = fields.Boolean()
notify_personal = fields.Boolean()
notify_jefe_area = fields.Boolean()
And the error I get:
Error:
Odoo Server Error
Traceback (most recent call last):
File "/opt/odoo/odoo/odoo/http.py", line 624, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "/opt/odoo/odoo/odoo/http.py", line 310, in _handle_exception
raise pycompat.reraise(type(exception), exception, sys.exc_info()[2])
File "/opt/odoo/odoo/odoo/tools/pycompat.py", line 14, in reraise
raise value
File "/opt/odoo/odoo/odoo/http.py", line 669, in dispatch
result = self._call_function(**self.params)
File "/opt/odoo/odoo/odoo/http.py", line 350, in _call_function
return checked_call(self.db, *args, **kwargs)
File "/opt/odoo/odoo/odoo/service/model.py", line 94, in wrapper
return f(dbname, *args, **kwargs)
File "/opt/odoo/odoo/odoo/http.py", line 339, in checked_call
result = self.endpoint(*a, **kw)
File "/opt/odoo/odoo/odoo/http.py", line 915, in __call__
return self.method(*args, **kw)
File "/opt/odoo/odoo/odoo/http.py", line 515, in response_wrap
response = f(*args, **kw)
File "/opt/odoo/odoo/addons/web/controllers/main.py", line 1331, in call_button
action = self._call_kw(model, method, args, kwargs)
File "/opt/odoo/odoo/addons/web/controllers/main.py", line 1319, in _call_kw
return call_kw(request.env[model], method, args, kwargs)
File "/opt/odoo/odoo/odoo/api.py", line 387, in call_kw
result = _call_kw_multi(method, model, args, kwargs)
File "/opt/odoo/odoo/odoo/api.py", line 374, in _call_kw_multi
result = method(recs, *args, **kwargs)
File "<decorator-gen-60>", line 2, in button_immediate_install
File "/opt/odoo/odoo/odoo/addons/base/models/ir_module.py", line 72, in check_and_log
return method(self, *args, **kwargs)
File "/opt/odoo/odoo/odoo/addons/base/models/ir_module.py", line 463, in button_immediate_install
return self._button_immediate_function(type(self).button_install)
File "/opt/odoo/odoo/odoo/addons/base/models/ir_module.py", line 573, in _button_immediate_function
modules.registry.Registry.new(self._cr.dbname, update_module=True)
File "/opt/odoo/odoo/odoo/modules/registry.py", line 86, in new
odoo.modules.load_modules(registry._db, force_demo, status, update_module)
File "/opt/odoo/odoo/odoo/modules/loading.py", line 421, in load_modules
processed_modules += load_marked_modules(cr, graph,
File "/opt/odoo/odoo/odoo/modules/loading.py", line 313, in load_marked_modules
loaded, processed = load_module_graph(
File "/opt/odoo/odoo/odoo/modules/loading.py", line 202, in load_module_graph
registry.init_models(cr, model_names, {'module': package.name}, new_install)
File "/opt/odoo/odoo/odoo/modules/registry.py", line 369, in init_models
model._auto_init()
File "/opt/odoo/odoo/odoo/models.py", line 2529, in _auto_init
new = field.update_db(self, columns)
File "/opt/odoo/odoo/odoo/fields.py", line 857, in update_db
self.update_db_notnull(model, column)
File "/opt/odoo/odoo/odoo/fields.py", line 921, in update_db_notnull
sql.drop_not_null(model._cr, model._table, self.name)
File "/opt/odoo/odoo/odoo/tools/sql.py", line 119, in drop_not_null
cr.execute('ALTER TABLE "{}" ALTER COLUMN "{}" DROP NOT NULL'.format(tablename, columnname))
File "/opt/odoo/odoo/odoo/sql_db.py", line 173, in wrapper
return f(self, *args, **kwargs)
File "/opt/odoo/odoo/odoo/sql_db.py", line 250, in execute
res = self._obj.execute(query, params)
psycopg2.errors.UndefinedColumn: column "name" of relation "offer_stage" does not exist
After some trial and error, I tried to install a default module that is created with odoo-bin scaffold, and what was my surprise when I cound't install it neither.
The error I get when installing the default module is a collision with other tables of odoo packages, since I am in a test environment I tried removing those packages and, when trying to reinstall, the same error arose but with a different package. I can't figure out why this happens because, a priori, my package only depends on 'base'.
The code of the default module created with scaffold:
# -*- coding: utf-8 -*-
from odoo import models, fields, api
class borrar(models.Model):
_name = 'borrar.borrar'
_description = 'borrar.borrar'
name = fields.Char()
value = fields.Integer()
value2 = fields.Float(compute="_value_pc", store=True)
description = fields.Text()
#api.depends('value')
def _value_pc(self):
for record in self:
record.value2 = float(record.value) / 100
The error I get:
Error:
Odoo Server Error
Traceback (most recent call last):
File "/opt/odoo/odoo/odoo/http.py", line 624, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "/opt/odoo/odoo/odoo/http.py", line 310, in _handle_exception
raise pycompat.reraise(type(exception), exception, sys.exc_info()[2])
File "/opt/odoo/odoo/odoo/tools/pycompat.py", line 14, in reraise
raise value
File "/opt/odoo/odoo/odoo/http.py", line 669, in dispatch
result = self._call_function(**self.params)
File "/opt/odoo/odoo/odoo/http.py", line 350, in _call_function
return checked_call(self.db, *args, **kwargs)
File "/opt/odoo/odoo/odoo/service/model.py", line 94, in wrapper
return f(dbname, *args, **kwargs)
File "/opt/odoo/odoo/odoo/http.py", line 339, in checked_call
result = self.endpoint(*a, **kw)
File "/opt/odoo/odoo/odoo/http.py", line 915, in __call__
return self.method(*args, **kw)
File "/opt/odoo/odoo/odoo/http.py", line 515, in response_wrap
response = f(*args, **kw)
File "/opt/odoo/odoo/addons/web/controllers/main.py", line 1331, in call_button
action = self._call_kw(model, method, args, kwargs)
File "/opt/odoo/odoo/addons/web/controllers/main.py", line 1319, in _call_kw
return call_kw(request.env[model], method, args, kwargs)
File "/opt/odoo/odoo/odoo/api.py", line 387, in call_kw
result = _call_kw_multi(method, model, args, kwargs)
File "/opt/odoo/odoo/odoo/api.py", line 374, in _call_kw_multi
result = method(recs, *args, **kwargs)
File "<decorator-gen-60>", line 2, in button_immediate_install
File "/opt/odoo/odoo/odoo/addons/base/models/ir_module.py", line 72, in check_and_log
return method(self, *args, **kwargs)
File "/opt/odoo/odoo/odoo/addons/base/models/ir_module.py", line 463, in button_immediate_install
return self._button_immediate_function(type(self).button_install)
File "/opt/odoo/odoo/odoo/addons/base/models/ir_module.py", line 573, in _button_immediate_function
modules.registry.Registry.new(self._cr.dbname, update_module=True)
File "/opt/odoo/odoo/odoo/modules/registry.py", line 86, in new
odoo.modules.load_modules(registry._db, force_demo, status, update_module)
File "/opt/odoo/odoo/odoo/modules/loading.py", line 467, in load_modules
env[model]._check_removed_columns(log=True)
File "/opt/odoo/odoo/odoo/models.py", line 2447, in _check_removed_columns
tools.drop_not_null(cr, self._table, row['attname'])
File "/opt/odoo/odoo/odoo/tools/sql.py", line 119, in drop_not_null
cr.execute('ALTER TABLE "{}" ALTER COLUMN "{}" DROP NOT NULL'.format(tablename, columnname))
File "/opt/odoo/odoo/odoo/sql_db.py", line 173, in wrapper
return f(self, *args, **kwargs)
File "/opt/odoo/odoo/odoo/sql_db.py", line 250, in execute
res = self._obj.execute(query, params)
psycopg2.errors.UndefinedColumn: column "rows" of relation "product_packaging" does not exist
However, the table borrar_borrar does get created:
link to image showing table in pgadmin4
This only happens with modules created by me, I have downloaded several modules from github and the official Odoo store and all of them install flawlessly.
Note: for ease of maintenance I have the modules in a git repository and I have soft-linked them to the custom-addons folder in the odoo directory. I have also tried placing them directly in the directory and the errors are the same.
I found out the solution. I'm writing it here in case someone face the same problem in the future.
The issue was that I had a Foreign Data Wrapper (FDW) to read data from another database and, for some reason, it was causing some kind of interference with the database I was working on. When I removed the FDW, everything worked as expected.

problem django get() returns two values postgresql

hello i have been this problem since i change sqlite to postgresql when it was empty i hit migrate and create tables when i create superuser it bugs but still creates admin users , and when its creates i cannt log in so its basic django admin and should not be something different how can i fix this? is it wrong migrate or?
and this is traceback when i create superuser
Traceback (most recent call last):
File "manage.py", line 15, in <module>
execute_from_command_line(sys.argv)
File "/var/www/html/web/venv/lib/python3.8/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line
utility.execute()
File "/var/www/html/web/venv/lib/python3.8/site-packages/django/core/management/__init__.py", line 395, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/var/www/html/web/venv/lib/python3.8/site-packages/django/core/management/base.py", line 330, in run_from_argv
self.execute(*args, **cmd_options)
File "/var/www/html/web/venv/lib/python3.8/site-packages/django/contrib/auth/management/commands/createsuperuser.py", line 79, in execute
return super().execute(*args, **options)
File "/var/www/html/web/venv/lib/python3.8/site-packages/django/core/management/base.py", line 371, in execute
output = self.handle(*args, **options)
File "/var/www/html/web/venv/lib/python3.8/site-packages/django/contrib/auth/management/commands/createsuperuser.py", line 189, in handle
self.UserModel._default_manager.db_manager(database).create_superuser(**user_data)
File "/var/www/html/web/venv/lib/python3.8/site-packages/django/contrib/auth/models.py", line 157, in create_superuser
return self._create_user(username, email, password, **extra_fields)
File "/var/www/html/web/venv/lib/python3.8/site-packages/django/contrib/auth/models.py", line 140, in _create_user
user.save(using=self._db)
File "/var/www/html/web/venv/lib/python3.8/site-packages/django/contrib/auth/base_user.py", line 67, in save
super().save(*args, **kwargs)
File "/var/www/html/web/venv/lib/python3.8/site-packages/django/db/models/base.py", line 753, in save
self.save_base(using=using, force_insert=force_insert,
File "/var/www/html/web/venv/lib/python3.8/site-packages/django/db/models/base.py", line 801, in save_base
post_save.send(
File "/var/www/html/web/venv/lib/python3.8/site-packages/django/dispatch/dispatcher.py", line 177, in send
return [
File "/var/www/html/web/venv/lib/python3.8/site-packages/django/dispatch/dispatcher.py", line 178, in <listcomp>
(receiver, receiver(signal=self, sender=sender, **named))
File "/var/www/html/web/users/signals.py", line 11, in create_profile
Profile.objects.create(user=instance)
File "/var/www/html/web/venv/lib/python3.8/site-packages/django/db/models/manager.py", line 85, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/var/www/html/web/venv/lib/python3.8/site-packages/django/db/models/query.py", line 447, in create
obj.save(force_insert=True, using=self.db)
File "/var/www/html/web/users/models.py", line 25, in save
img = Image.open(self.image.path)
File "/var/www/html/web/venv/lib/python3.8/site-packages/django/db/models/fields/files.py", line 57, in path
return self.storage.path(self.name)
File "/var/www/html/webst/venv/lib/python3.8/site-packages/django/core/files/storage.py", line 116, in path
raise NotImplementedError("This backend doesn't support absolute paths.")
NotImplementedError: This backend doesn't support absolute paths.
Probably you have two users with same login. You could try to get all users with login which you use to login in admin panel
python manage.py shell
from users.models import User
User.objects.filter(login=your_login)
than you will get queryset, and if there more than one object with same login, just delete it
Looks that its something with the settings.py. Please be sure that the settings its ok:
https://docs.djangoproject.com/en/3.1/ref/settings/#std:setting-HOST
Share us the settings.py for more help

Can't Access Database After Editing Views in Odoo 10: Internal Server Error

I'm working on Odoo 10.0 CE (Ubuntu 18.04.1 LTS).
After editing views from Technical (Login Layout - web.login_layout) I set its Inherited View with Web layout - web.layout. I couldnt login to the database & its showing like this (traceback attached below). How to fix this?
I tried to update the database & module through command line as User, but it didnt work, still can't login to the database
Is there any way that i can edit/undo the Views (Web layout - web.layout) through command line (database)?
Thanks :)
500: Internal Server Error
Error
Error message:
load could not load template
Template: web.layout
Traceback
Traceback (most recent call last):
File "/opt/odoo/addons/website/models/ir_http.py", line 274, in _handle_exception
response = super(Http, cls)._handle_exception(exception)
File "/opt/odoo/odoo/addons/base/ir/ir_http.py", line 169, in _handle_exception
return request._handle_exception(exception)
File "/opt/odoo/odoo/http.py", line 775, in _handle_exception
return super(HttpRequest, self)._handle_exception(exception)
File "/opt/odoo/odoo/addons/base/ir/ir_http.py", line 195, in _dispatch
result = request.dispatch()
File "/opt/odoo/odoo/http.py", line 834, in dispatch
r = self._call_function(**self.params)
File "/opt/odoo/odoo/http.py", line 334, in _call_function
return checked_call(self.db, *args, **kwargs)
File "/opt/odoo/odoo/service/model.py", line 101, in wrapper
return f(dbname, *args, **kwargs)
File "/opt/odoo/odoo/http.py", line 330, in checked_call
result.flatten()
File "/opt/odoo/odoo/http.py", line 1277, in flatten
self.response.append(self.render())
File "/opt/odoo/odoo/http.py", line 1270, in render
return env["ir.ui.view"].render_template(self.template, self.qcontext)
File "/opt/odoo/addons/app_odoo_customize/models/ir_ui_view.py", line 18, in render_template
return super(View, self).render_template(template, values=values, engine=engine)
File "/opt/odoo/odoo/addons/base/ir/ir_ui_view.py", line 1049, in render_template
return self.browse(self.get_view_id(template)).render(values, engine)
File "/opt/odoo/addons/website/models/ir_ui_view.py", line 115, in render
return super(View, self).render(values, engine=engine)
File "/opt/odoo/addons/web_editor/models/ir_ui_view.py", line 26, in render
return super(IrUiView, self).render(values=values, engine=engine)
File "/opt/odoo/odoo/addons/base/ir/ir_ui_view.py", line 1069, in render
return self.env[engine].render(self.id, qcontext)
File "/opt/odoo/odoo/addons/base/ir/ir_qweb/ir_qweb.py", line 53, in render
return super(IrQWeb, self).render(id_or_xml_id, values=values, **context)
File "/opt/odoo/odoo/addons/base/ir/ir_qweb/qweb.py", line 249, in render
self.compile(template, options)(self, body.append, values or {})
File "/opt/odoo/odoo/addons/base/ir/ir_qweb/qweb.py", line 318, in _compiled_fn
raise e
QWebException: None
Traceback (most recent call last):
File "/opt/odoo/odoo/addons/base/ir/ir_qweb/qweb.py", line 342, in get_template
document = options.get('load', self.load)(template, options)
File "/opt/odoo/odoo/addons/base/ir/ir_qweb/ir_qweb.py", line 81, in load
template = env['ir.ui.view'].read_template(name)
File "/opt/odoo/odoo/addons/base/ir/ir_ui_view.py", line 944, in read_template
return self._read_template(self.get_view_id(xml_id))
File "<decorator-gen-9>", line 2, in _read_template
File "/opt/odoo/odoo/tools/cache.py", line 87, in lookup
value = d[key] = self.method(*args, **kwargs)
File "/opt/odoo/odoo/addons/base/ir/ir_ui_view.py", line 935, in _read_template
arch = self.browse(view_id).read_combined(['arch'])['arch']
File "/opt/odoo/odoo/addons/base/ir/ir_ui_view.py", line 674, in read_combined
arch = self.apply_view_inheritance(arch_tree, root.id, self.model)
File "/opt/odoo/odoo/addons/base/ir/ir_ui_view.py", line 623, in apply_view_inheritance
source = self.apply_inheritance_specs(source, specs_tree, view_id)
File "/opt/odoo/odoo/addons/base/ir/ir_ui_view.py", line 601, in apply_inheritance_specs
self.raise_view_error(_("Element '%s' cannot be located in parent view") % tag, inherit_id)
File "/opt/odoo/odoo/addons/base/ir/ir_ui_view.py", line 474, in raise_view_error
raise ValueError(message)
ValueError: Element '<t name="Web layout" t-name="web.layout">' cannot be located in parent view
Error context:
View `Web layout`
[view_id: 165, xml_id: web.layout, model: n/a, parent_id: 166]
load could not load template
Template: web.layout

django mongo engine - DatabaseError: Unknown option auto_start_request

After going into the django shell and creating the following entry:
from blinks.models import *
q=Questions(
questions='What is science?',
tags=['science','psychology']
)
i am not able to use
q.save()
i am getting the following error message
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/Users/sunilkumar/blink2/lib/python2.7/site-packages/django/db/models/base.py", line 548, in save
force_update=force_update, update_fields=update_fields)
File "/Users/sunilkumar/blink2/lib/python2.7/site-packages/django/db/models/base.py", line 668, in save_base
result = manager._insert([self], fields=fields, return_id=update_pk, using=using, raw=raw)
File "/Users/sunilkumar/blink2/lib/python2.7/site-packages/django/db/models/manager.py", line 215, in _insert
return insert_query(self.model, objs, fields, **kwargs)
File "/Users/sunilkumar/blink2/lib/python2.7/site-packages/django/db/models/query.py", line 1675, in insert_query
return query.get_compiler(using=using).execute_sql(return_id)
File "/Users/sunilkumar/blink2/lib/python2.7/site-packages/djangotoolbox/db/basecompiler.py", line 592, in execute_sql
key = self.insert(to_insert, return_id=return_id)
File "/Users/sunilkumar/blink2/lib/python2.7/site-packages/django_mongodb_engine/compiler.py", line 84, in wrapper
return func(*args, **kwargs)
File "/Users/sunilkumar/blink2/lib/python2.7/site-packages/django_mongodb_engine/compiler.py", line 387, in insert
collection = self.get_collection()
File "/Users/sunilkumar/blink2/lib/python2.7/site-packages/django_mongodb_engine/compiler.py", line 296, in get_collection
return self.connection.get_collection(self.query.get_meta().db_table)
File "/Users/sunilkumar/blink2/lib/python2.7/site-packages/django_mongodb_engine/base.py", line 196, in get_collection
collection = self.collection_class(self.database, name, **kwargs)
File "/Users/sunilkumar/blink2/lib/python2.7/site-packages/django_mongodb_engine/base.py", line 204, in __getattr__
self._connect()
File "/Users/sunilkumar/blink2/lib/python2.7/site-packages/django_mongodb_engine/base.py", line 261, in _connect
self.connection = connection_class(**conn_options)
File "/Users/sunilkumar/blink2/lib/python2.7/site-packages/pymongo/mongo_client.py", line 322, in __init__
username, password, dbase, opts)
File "/Users/sunilkumar/blink2/lib/python2.7/site-packages/pymongo/client_options.py", line 108, in __init__
options = dict([validate(opt, val) for opt, val in iteritems(options)])
File "/Users/sunilkumar/blink2/lib/python2.7/site-packages/pymongo/common.py", line 425, in validate
value = validator(option, value)
File "/Users/sunilkumar/blink2/lib/python2.7/site-packages/pymongo/common.py", line 100, in raise_config_error
raise ConfigurationError("Unknown option %s" % (key,))
DatabaseError: Unknown option auto_start_request
My folder structure is as follows:
/blink/
- blink
- __init__.py
- settings.py
- urls.py
- wsgi.py
- blinks (app folder)
- __init__.py
- models.py
- views.py
- tests.py
- manage.py
The versions used are:
Python 2.7.5+
Django-1.5.11-py2.7
pymongo-3.0.1-py2.7
django_mongodb_engine-0.5.2-py2.7
djangotoolbox-1.6.2-py2.7
Is there anything i am missing?
Can somebody please help me on what the problem is? i am new to django and mongodb. I am not able to find the solution anywhere.
I had to downgrade the pymongo-3.0.1 to pymongo 2.7 which solved the issue. This error is because of the fact that most of the keywords has been changed or deprecated in pymongo-3.0.1.
I had this same problem.
Choose an auto-generated password instead of your password.
That worked for me

Django project looking for "attribute '_session_cache'"

So I have a Django project that doesn't use a database (the 'DATABASES' setting is commented out). I chose to use Django as there's a chance I will need the database functionality in the future. Anyway, I've been working on and off of tbhis project for a couple of months with no problems. I'm running Linux Mint and have had no troubles using the python manage.py runserver command so far.
Well, today I fired up the app and started the local server with no problems. I then tried to open the app in my browser and received the rather hideous error message:
Traceback (most recent call last):
File "/home/peter/.virtualenvs/vis_it/lib/python3.3/site-packages/django/contrib/sessions/backends/base.py", line 170, in _get_session
return self._session_cache
AttributeError: 'SessionStore' object has no attribute '_session_cache'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/peter/.virtualenvs/vis_it/lib/python3.3/site-packages/django/core/handlers/base.py", line 87, in get_response
response = middleware_method(request)
File "/home/peter/.virtualenvs/vis_it/lib/python3.3/site-packages/django/contrib/auth/middleware.py", line 34, in process_request
if user and hasattr(user, 'get_session_auth_hash'):
File "/home/peter/.virtualenvs/vis_it/lib/python3.3/site-packages/django/utils/functional.py", line 224, in inner
self._setup()
File "/home/peter/.virtualenvs/vis_it/lib/python3.3/site-packages/django/utils/functional.py", line 357, in _setup
self._wrapped = self._setupfunc()
File "/home/peter/.virtualenvs/vis_it/lib/python3.3/site-packages/django/contrib/auth/middleware.py", line 23, in <lambda>
request.user = SimpleLazyObject(lambda: get_user(request))
File "/home/peter/.virtualenvs/vis_it/lib/python3.3/site-packages/django/contrib/auth/middleware.py", line 11, in get_user
request._cached_user = auth.get_user(request)
File "/home/peter/.virtualenvs/vis_it/lib/python3.3/site-packages/django/contrib/auth/__init__.py", line 151, in get_user
user_id = request.session[SESSION_KEY]
File "/home/peter/.virtualenvs/vis_it/lib/python3.3/site-packages/django/contrib/sessions/backends/base.py", line 49, in __getitem__
return self._session[key]
File "/home/peter/.virtualenvs/vis_it/lib/python3.3/site-packages/django/contrib/sessions/backends/base.py", line 175, in _get_session
self._session_cache = self.load()
File "/home/peter/.virtualenvs/vis_it/lib/python3.3/site-packages/django/contrib/sessions/backends/db.py", line 21, in load
expire_date__gt=timezone.now()
File "/home/peter/.virtualenvs/vis_it/lib/python3.3/site-packages/django/db/models/manager.py", line 92, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/home/peter/.virtualenvs/vis_it/lib/python3.3/site-packages/django/db/models/query.py", line 351, in get
num = len(clone)
File "/home/peter/.virtualenvs/vis_it/lib/python3.3/site-packages/django/db/models/query.py", line 122, in __len__
self._fetch_all()
File "/home/peter/.virtualenvs/vis_it/lib/python3.3/site-packages/django/db/models/query.py", line 966, in _fetch_all
self._result_cache = list(self.iterator())
File "/home/peter/.virtualenvs/vis_it/lib/python3.3/site-packages/django/db/models/query.py", line 265, in iterator
for row in compiler.results_iter():
File "/home/peter/.virtualenvs/vis_it/lib/python3.3/site-packages/django/db/models/sql/compiler.py", line 700, in results_iter
for rows in self.execute_sql(MULTI):
File "/home/peter/.virtualenvs/vis_it/lib/python3.3/site-packages/django/db/models/sql/compiler.py", line 775, in execute_sql
sql, params = self.as_sql()
File "/home/peter/.virtualenvs/vis_it/lib/python3.3/site-packages/django/db/models/sql/compiler.py", line 100, in as_sql
out_cols, s_params = self.get_columns(with_col_aliases)
File "/home/peter/.virtualenvs/vis_it/lib/python3.3/site-packages/django/db/models/sql/compiler.py", line 246, in get_columns
col_aliases)
File "/home/peter/.virtualenvs/vis_it/lib/python3.3/site-packages/django/db/models/sql/compiler.py", line 328, in get_default_columns
r = '%s.%s' % (qn(alias), qn2(column))
File "/home/peter/.virtualenvs/vis_it/lib/python3.3/site-packages/django/db/models/sql/compiler.py", line 62, in __call__
r = self.connection.ops.quote_name(name)
File "/home/peter/.virtualenvs/vis_it/lib/python3.3/site-packages/django/db/backends/dummy/base.py", line 18, in complain
raise ImproperlyConfigured("settings.DATABASES is improperly configured. "
django.core.exceptions.ImproperlyConfigured: settings.DATABASES is improperly configured. Please supply the ENGINE value. Check settings documentation for more details.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/peter/.virtualenvs/vis_it/lib/python3.3/site-packages/django/contrib/sessions/backends/base.py", line 170, in _get_session
return self._session_cache
AttributeError: 'SessionStore' object has no attribute '_session_cache'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3.3/wsgiref/handlers.py", line 137, in run
self.result = application(self.environ, self.start_response)
File "/home/peter/.virtualenvs/vis_it/lib/python3.3/site-packages/django/contrib/staticfiles/handlers.py", line 64, in __call__
return self.application(environ, start_response)
File "/home/peter/.virtualenvs/vis_it/lib/python3.3/site-packages/django/core/handlers/wsgi.py", line 187, in __call__
response = self.get_response(request)
File "/home/peter/.virtualenvs/vis_it/lib/python3.3/site-packages/django/core/handlers/base.py", line 199, in get_response
response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
File "/home/peter/.virtualenvs/vis_it/lib/python3.3/site-packages/django/core/handlers/base.py", line 236, in handle_uncaught_exception
return debug.technical_500_response(request, *exc_info)
File "/home/peter/.virtualenvs/vis_it/lib/python3.3/site-packages/django/views/debug.py", line 91, in technical_500_response
html = reporter.get_traceback_html()
File "/home/peter/.virtualenvs/vis_it/lib/python3.3/site-packages/django/views/debug.py", line 349, in get_traceback_html
c = Context(self.get_traceback_data(), use_l10n=False)
File "/home/peter/.virtualenvs/vis_it/lib/python3.3/site-packages/django/views/debug.py", line 307, in get_traceback_data
frames = self.get_traceback_frames()
File "/home/peter/.virtualenvs/vis_it/lib/python3.3/site-packages/django/views/debug.py", line 465, in get_traceback_frames
'vars': self.filter.get_traceback_frame_variables(self.request, tb.tb_frame),
File "/home/peter/.virtualenvs/vis_it/lib/python3.3/site-packages/django/views/debug.py", line 232, in get_traceback_frame_variables
cleansed[name] = self.cleanse_special_types(request, value)
File "/home/peter/.virtualenvs/vis_it/lib/python3.3/site-packages/django/views/debug.py", line 187, in cleanse_special_types
if isinstance(value, HttpRequest):
File "/home/peter/.virtualenvs/vis_it/lib/python3.3/site-packages/django/utils/functional.py", line 224, in inner
self._setup()
File "/home/peter/.virtualenvs/vis_it/lib/python3.3/site-packages/django/utils/functional.py", line 357, in _setup
self._wrapped = self._setupfunc()
File "/home/peter/.virtualenvs/vis_it/lib/python3.3/site-packages/django/contrib/auth/middleware.py", line 23, in <lambda>
request.user = SimpleLazyObject(lambda: get_user(request))
File "/home/peter/.virtualenvs/vis_it/lib/python3.3/site-packages/django/contrib/auth/middleware.py", line 11, in get_user
request._cached_user = auth.get_user(request)
File "/home/peter/.virtualenvs/vis_it/lib/python3.3/site-packages/django/contrib/auth/__init__.py", line 151, in get_user
user_id = request.session[SESSION_KEY]
File "/home/peter/.virtualenvs/vis_it/lib/python3.3/site-packages/django/contrib/sessions/backends/base.py", line 49, in __getitem__
return self._session[key]
File "/home/peter/.virtualenvs/vis_it/lib/python3.3/site-packages/django/contrib/sessions/backends/base.py", line 175, in _get_session
self._session_cache = self.load()
File "/home/peter/.virtualenvs/vis_it/lib/python3.3/site-packages/django/contrib/sessions/backends/db.py", line 21, in load
expire_date__gt=timezone.now()
File "/home/peter/.virtualenvs/vis_it/lib/python3.3/site-packages/django/db/models/manager.py", line 92, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/home/peter/.virtualenvs/vis_it/lib/python3.3/site-packages/django/db/models/query.py", line 351, in get
num = len(clone)
File "/home/peter/.virtualenvs/vis_it/lib/python3.3/site-packages/django/db/models/query.py", line 122, in __len__
self._fetch_all()
File "/home/peter/.virtualenvs/vis_it/lib/python3.3/site-packages/django/db/models/query.py", line 966, in _fetch_all
self._result_cache = list(self.iterator())
File "/home/peter/.virtualenvs/vis_it/lib/python3.3/site-packages/django/db/models/query.py", line 265, in iterator
for row in compiler.results_iter():
File "/home/peter/.virtualenvs/vis_it/lib/python3.3/site-packages/django/db/models/sql/compiler.py", line 700, in results_iter
for rows in self.execute_sql(MULTI):
File "/home/peter/.virtualenvs/vis_it/lib/python3.3/site-packages/django/db/models/sql/compiler.py", line 775, in execute_sql
sql, params = self.as_sql()
File "/home/peter/.virtualenvs/vis_it/lib/python3.3/site-packages/django/db/models/sql/compiler.py", line 100, in as_sql
out_cols, s_params = self.get_columns(with_col_aliases)
File "/home/peter/.virtualenvs/vis_it/lib/python3.3/site-packages/django/db/models/sql/compiler.py", line 246, in get_columns
col_aliases)
File "/home/peter/.virtualenvs/vis_it/lib/python3.3/site-packages/django/db/models/sql/compiler.py", line 328, in get_default_columns
r = '%s.%s' % (qn(alias), qn2(column))
File "/home/peter/.virtualenvs/vis_it/lib/python3.3/site-packages/django/db/models/sql/compiler.py", line 62, in __call__
r = self.connection.ops.quote_name(name)
File "/home/peter/.virtualenvs/vis_it/lib/python3.3/site-packages/django/db/backends/dummy/base.py", line 18, in complain
raise ImproperlyConfigured("settings.DATABASES is improperly configured. "
django.core.exceptions.ImproperlyConfigured: settings.DATABASES is improperly configured. Please supply the ENGINE value. Check settings documentation for more details.
[28/Nov/2014 13:18:54] "GET / HTTP/1.1" 500 59
I've not touched the app since I last worked on it and it was working fine then. I really have no idea what this is talking about as I have no caches implemented and am not using a database... I've asked a few colleges who are familiar with Django and have no idea what this is either. Any Ideas? I've also tried setting DATABASES to an empty dict {} on the advice of a post online but to no effect. At a bit of a loss.
EDIT: Thought I should mention that in the interim since I last touched this project, I've since started and set up a new Django project that does use a database. Is it possible that this project is somehow cached and breaking the one I'm currently trying to work on?
EDIT2: I should point out that this webapp is currently live and working at http://mrcagney-maps.com. The code is exactly the same (having not touched it since I last pushed to the server). Really weird.
For future Googlers - I ran into this issue and the above solutions did not work for me. What did work for me was clearing/deleting my cookies in Chrome for the 127.0.0.1 URL. So go to Settings or press CMD+, then Cookies and other site data, then find 127.0.0.1 or localhost and delete those cookies. Refresh the local dev host page and the error should be gone. This has something to do with a corrupted session / cookie file.
I'm not sure why I started to get this error, it involved an upgrade though. I just deleted all the sessions and after logging back in all was well.
# from the shell but equivalent sql would work fine too
from django.contrib.sessions.models import Session
Session.objects.all().delete()
The error AttributeError: 'SessionStore' object has no attribute '_session_cache' can stem from the database not having a django_session table. However, since you are not using a table, you would need to make sure that you don't have the 'django.contrib.sessions.middleware.SessionMiddleware' in your MIDDLEWARE_CLASSES in the project's settings file. If it is in there, it will look for a database table which stores the sessions, causing the above error.
Here is what worked for me. Since there is no databases in your application. Admin page looks for the database be it default. So first lets create the default databases.
Shut down your servers and run
python manage.py makemigrations
python manage.py migrate
Now create the admin or superuser for your application. Fill username and password.
python manage.py createsuperuser
Now restart your server and go the admin page
python manage.py runserver
Throwed the same error for me after upgraded my wagtail version... So, for me worked even simpler solution or u didn't noticed already :D Actually I opened the browser > F12 > Storage Tab and Delete all Cookies and all other Cached Data
Users facing this issue via Postman please make sure that the value in the request header for Cache-Control is no-cache.
If not then clear the cookie data for the domain.
In normal case when we use
from django.http import JsonResponse
for sending response we have no need to uses sessions.
But when we use some package such as djangorestframework we force to use sessions.
Sessions need storage place in sqllite,mysql ,...or others
then we need run these commands:
python manage.py makemigrations
python manage.py migrate

Categories