google-code-export / django-treemenus

Automatically exported from code.google.com/p/django-treemenus
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Delete Root Element #37

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
When tree root node is select for delete this output a error of foreign key

Environment:

Request Method: POST
Request URL: http://127.0.0.1:8000/admin/website/menu/1/delete/
Django Version: 1.0.2 final
Python Version: 2.6.2
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.admin',
 'listPedidosLivros.website',
 'treemenus']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware')

Traceback:
File "/var/lib/python-support/python2.6/django/core/handlers/base.py" in
get_response
  86.                 response = callback(request, *callback_args,
**callback_kwargs)
File "/var/lib/python-support/python2.6/django/contrib/admin/sites.py" in root
  157.                 return self.model_page(request, *url.split('/', 2))
File "/var/lib/python-support/python2.6/django/views/decorators/cache.py"
in _wrapped_view_func
  44.         response = view_func(request, *args, **kwargs)
File "/var/lib/python-support/python2.6/django/contrib/admin/sites.py" in
model_page
  176.         return admin_obj(request, rest_of_url)
File
"/home/paulo/Programacao/python/listPedidosLivros/../listPedidosLivros/website/a
dmin.py"
in __call__
  134.         return super(MenuAdmin, self).__call__(request, url)
File "/var/lib/python-support/python2.6/django/contrib/admin/options.py" in
__call__
  195.             return self.delete_view(request, unquote(url[:-7]))
File "/var/lib/python-support/python2.6/django/contrib/admin/options.py" in
delete_view
  685.             obj.delete()
File
"/home/paulo/Programacao/python/listPedidosLivros/../listPedidosLivros/website/m
odels.py"
in delete
  246.             self.root_item.delete()
File
"/home/paulo/Programacao/python/listPedidosLivros/../listPedidosLivros/website/m
odels.py"
in delete
  176.         super(MenuItem, self).delete()
File "/var/lib/python-support/python2.6/django/db/models/base.py" in delete
  447.         delete_objects(seen_objs)
File "/var/lib/python-support/python2.6/django/db/models/query.py" in
delete_objects
  870.         del_query.delete_batch(pk_list)
File "/var/lib/python-support/python2.6/django/db/models/sql/subqueries.py"
in delete_batch
  86.             self.do_query(self.model._meta.db_table, where)
File "/var/lib/python-support/python2.6/django/db/models/sql/subqueries.py"
in do_query
  34.         self.execute_sql(None)
File "/var/lib/python-support/python2.6/django/db/models/sql/query.py" in
execute_sql
  1734.         cursor.execute(sql, params)
File "/var/lib/python-support/python2.6/django/db/backends/util.py" in execute
  19.             return self.cursor.execute(sql, params)
File "/var/lib/python-support/python2.6/django/db/backends/mysql/base.py"
in execute
  83.             return self.cursor.execute(query, args)
File "/var/lib/python-support/python2.6/MySQLdb/cursors.py" in execute
  166.             self.errorhandler(self, exc, value)
File "/var/lib/python-support/python2.6/MySQLdb/connections.py" in
defaulterrorhandler
  35.     raise errorclass, errorvalue

Exception Type: IntegrityError at /admin/website/menu/1/delete/
Exception Value: (1451, 'Cannot delete or update a parent row: a foreign
key constraint fails (`PRD_CORP_BKP`.`treemenus_menuitem`, CONSTRAINT
`menu_id_refs_id_635b36c6` FOREIGN KEY (`menu_id`) REFERENCES
`treemenus_menu` (`id`))')

I'm using  django-treemenus0.8.6 on Ubuntu Linux System

Original issue reported on code.google.com by paulo.ubuntu on 5 Mar 2010 at 8:26

GoogleCodeExporter commented 9 years ago
The root item is always required, and it should not be visible from the admin. 
If you can see it and 
delete it from the admin, it means that you're configuration is incorrect and 
you're using the wrong 
templates.

Original comment by jpha...@gmail.com on 24 Apr 2010 at 9:44