Hello,
I have installed django-oscar 3.2 in pythonanywhere using mysql
database, but when I try to add a categoriy from the panel, it gives
a 500 erroe with the following traceback:
2023-11-10 14:50:53,432: Internal Server Error: /dashboard/catalogue/categories/create/
Traceback (most recent call last):
File "/home/marketverde/market_verde/venv/lib/python3.10/site-packages/django/db/backends/utils.py", line 89, in _execute
return self.cursor.execute(sql, params)
File "/home/marketverde/market_verde/venv/lib/python3.10/site-packages/django/db/backends/mysql/base.py", line 75, in execute
return self.cursor.execute(query, args)
File "/home/marketverde/market_verde/venv/lib/python3.10/site-packages/MySQLdb/cursors.py", line 179, in execute
res = self._query(mogrified_query)
File "/home/marketverde/market_verde/venv/lib/python3.10/site-packages/MySQLdb/cursors.py", line 330, in _query
db.query(q)
File "/home/marketverde/market_verde/venv/lib/python3.10/site-packages/MySQLdb/connections.py", line 255, in query
_mysql.connection.query(self, query)
MySQLdb.OperationalError: (1093, "You can't specify target table 'catalogue_category' for update in FROM clause")
**NO MATCH**
The above exception was the direct cause of the following exception:
**NO MATCH**
Traceback (most recent call last):
File "/home/marketverde/market_verde/venv/lib/python3.10/site-packages/django/core/handlers/exception.py", line 55, in inner
response = get_response(request)
File "/home/marketverde/market_verde/venv/lib/python3.10/site-packages/django/core/handlers/base.py", line 197, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/usr/local/lib/python3.10/contextlib.py", line 79, in inner
return func(*args, **kwds)
File "/home/marketverde/market_verde/venv/lib/python3.10/site-packages/django/contrib/auth/decorators.py", line 23, in _wrapper_view
return view_func(request, *args, **kwargs)
File "/home/marketverde/market_verde/venv/lib/python3.10/site-packages/django/views/generic/base.py", line 104, in view
return self.dispatch(request, *args, **kwargs)
File "/home/marketverde/market_verde/venv/lib/python3.10/site-packages/django/views/generic/base.py", line 143, in dispatch
return handler(request, *args, **kwargs)
File "/home/marketverde/market_verde/venv/lib/python3.10/site-packages/django/views/generic/edit.py", line 184, in post
return super().post(request, *args, **kwargs)
File "/home/marketverde/market_verde/venv/lib/python3.10/site-packages/django/views/generic/edit.py", line 153, in post
return self.form_valid(form)
File "/home/marketverde/market_verde/venv/lib/python3.10/site-packages/django/views/generic/edit.py", line 135, in form_valid
self.object = form.save()
File "/home/marketverde/market_verde/venv/lib/python3.10/site-packages/treebeard/forms.py", line 147, in save
self.instance = self._meta.model.add_root(instance=self.instance)
File "/home/marketverde/market_verde/venv/lib/python3.10/site-packages/treebeard/mp_tree.py", line 623, in add_root
return MP_AddRootHandler(cls, **kwargs).process()
File "/home/marketverde/market_verde/venv/lib/python3.10/site-packages/treebeard/mp_tree.py", line 341, in process
newobj.save()
File "/home/marketverde/market_verde/venv/lib/python3.10/site-packages/oscar/apps/catalogue/abstract_models.py", line 225, in save
super().save(*args, **kwargs)
File "/home/marketverde/market_verde/venv/lib/python3.10/site-packages/django/db/models/base.py", line 814, in save
self.save_base(
File "/home/marketverde/market_verde/venv/lib/python3.10/site-packages/django/db/models/base.py", line 892, in save_base
post_save.send(
File "/home/marketverde/market_verde/venv/lib/python3.10/site-packages/django/dispatch/dispatcher.py", line 176, in send
return [
File "/home/marketverde/market_verde/venv/lib/python3.10/site-packages/django/dispatch/dispatcher.py", line 177, in <listcomp>
(receiver, receiver(signal=self, sender=sender, **named))
File "/home/marketverde/market_verde/venv/lib/python3.10/site-packages/oscar/apps/catalogue/receivers.py", line 43, in post_save_set_ancestors_are_public
instance.set_ancestors_are_public()
File "/home/marketverde/market_verde/venv/lib/python3.10/site-packages/oscar/apps/catalogue/abstract_models.py", line 236, in set_ancestors_are_public
self.get_descendants_and_self().update(
File "/home/marketverde/market_verde/venv/lib/python3.10/site-packages/django/db/models/query.py", line 1206, in update
rows = query.get_compiler(self.db).execute_sql(CURSOR)
File "/home/marketverde/market_verde/venv/lib/python3.10/site-packages/django/db/models/sql/compiler.py", line 1984, in execute_sql
cursor = super().execute_sql(result_type)
File "/home/marketverde/market_verde/venv/lib/python3.10/site-packages/django/db/models/sql/compiler.py", line 1562, in execute_sql
cursor.execute(sql, params)
File "/home/marketverde/market_verde/venv/lib/python3.10/site-packages/django/db/backends/utils.py", line 67, in execute
return self._execute_with_wrappers(
File "/home/marketverde/market_verde/venv/lib/python3.10/site-packages/django/db/backends/utils.py", line 80, in _execute_with_wrappers
return executor(sql, params, many, context)
File "/home/marketverde/market_verde/venv/lib/python3.10/site-packages/django/db/backends/utils.py", line 84, in _execute
with self.db.wrap_database_errors:
File "/home/marketverde/market_verde/venv/lib/python3.10/site-packages/django/db/utils.py", line 91, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
File "/home/marketverde/market_verde/venv/lib/python3.10/site-packages/django/db/backends/utils.py", line 89, in _execute
return self.cursor.execute(sql, params)
File "/home/marketverde/market_verde/venv/lib/python3.10/site-packages/django/db/backends/mysql/base.py", line 75, in execute
return self.cursor.execute(query, args)
File "/home/marketverde/market_verde/venv/lib/python3.10/site-packages/MySQLdb/cursors.py", line 179, in execute
res = self._query(mogrified_query)
File "/home/marketverde/market_verde/venv/lib/python3.10/site-packages/MySQLdb/cursors.py", line 330, in _query
db.query(q)
File "/home/marketverde/market_verde/venv/lib/python3.10/site-packages/MySQLdb/connections.py", line 255, in query
_mysql.connection.query(self, query)
django.db.utils.OperationalError: (1093, "You can't specify target table 'catalogue_category' for update in FROM clause")
The same is working in localhost using sqlite database. Do you have
any clue on what is happening?
Thanks,
Javier.