I am trying to view my table in the django-admin panel but i keep reciving no such table (table name) when i am sure it exists. I am using django-treebeard to create a hierarchical data.
I have also tried deleting the sql table and migrations. it was working fine before adding MP node. models.py :
from django.db import models
from vessels.models import Vessel
from treebeard.mp_tree import MP_Node
# Create your models here.
class Component(MP_Node):
name = models.CharField(max_length=200, blank=True, null=True)
manufacturer = models.CharField(max_length=200, blank=True, null=True)
model = models.CharField(max_length=200, blank=True, null=True)
type = models.CharField(max_length=200, blank=True, null=True)
remarks = models.TextField(blank=True, null=True)
vessel = models.ForeignKey(
Vessel, blank=True, null=True, on_delete=models.CASCADE, related_name='vessel_components')
def __str__(self):
return self.name
admin.py :
from django.contrib import admin
from .models import Component
# Register your models here.
admin.site.register(Component)
Full traceback:
Traceback (most recent call last):
File "C:\Users\DRT\Desktop\nitrofleet\venv\lib\site-packages\django\db\backends\utils.py", line 89, in _execute
return self.cursor.execute(sql, params)
File "C:\Users\DRT\Desktop\nitrofleet\venv\lib\site-packages\django\db\backends\sqlite3\base.py", line 477, in execute
return Database.Cursor.execute(self, query, params)
The above exception (no such table: maintenance_component) was the direct cause of the following exception:
File "C:\Users\DRT\Desktop\nitrofleet\venv\lib\site-packages\django\core\handlers\exception.py", line 55, in inner
response = get_response(request)
File "C:\Users\DRT\Desktop\nitrofleet\venv\lib\site-packages\django\core\handlers\base.py", line 197, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "C:\Users\DRT\Desktop\nitrofleet\venv\lib\site-packages\django\contrib\admin\options.py", line 683, in wrapper
return self.admin_site.admin_view(view)(*args, **kwargs)
File "C:\Users\DRT\Desktop\nitrofleet\venv\lib\site-packages\django\utils\decorators.py", line 133, in _wrapped_view
response = view_func(request, *args, **kwargs)
File "C:\Users\DRT\Desktop\nitrofleet\venv\lib\site-packages\django\views\decorators\cache.py", line 62, in _wrapped_view_func
response = view_func(request, *args, **kwargs)
File "C:\Users\DRT\Desktop\nitrofleet\venv\lib\site-packages\django\contrib\admin\sites.py", line 242, in inner
return view(request, *args, **kwargs)
File "C:\Users\DRT\Desktop\nitrofleet\venv\lib\site-packages\django\utils\decorators.py", line 46, in _wrapper
return bound_method(*args, **kwargs)
File "C:\Users\DRT\Desktop\nitrofleet\venv\lib\site-packages\django\utils\decorators.py", line 133, in _wrapped_view
response = view_func(request, *args, **kwargs)
File "C:\Users\DRT\Desktop\nitrofleet\venv\lib\site-packages\django\contrib\admin\options.py", line 1926, in changelist_view
cl = self.get_changelist_instance(request)
File "C:\Users\DRT\Desktop\nitrofleet\venv\lib\site-packages\django\contrib\admin\options.py", line 831, in get_changelist_instance
return ChangeList(
File "C:\Users\DRT\Desktop\nitrofleet\venv\lib\site-packages\django\contrib\admin\views\main.py", line 123, in __init__
self.get_results(request)
File "C:\Users\DRT\Desktop\nitrofleet\venv\lib\site-packages\django\contrib\admin\views\main.py", line 279, in get_results
result_count = paginator.count
File "C:\Users\DRT\Desktop\nitrofleet\venv\lib\site-packages\django\utils\functional.py", line 49, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "C:\Users\DRT\Desktop\nitrofleet\venv\lib\site-packages\django\core\paginator.py", line 96, in count
return c()
File "C:\Users\DRT\Desktop\nitrofleet\venv\lib\site-packages\django\db\models\query.py", line 470, in count
return self.query.get_count(using=self.db)
File "C:\Users\DRT\Desktop\nitrofleet\venv\lib\site-packages\django\db\models\sql\query.py", line 552, in get_count
number = obj.get_aggregation(using, ["__count"])["__count"]
File "C:\Users\DRT\Desktop\nitrofleet\venv\lib\site-packages\django\db\models\sql\query.py", line 537, in get_aggregation
result = compiler.execute_sql(SINGLE)
File "C:\Users\DRT\Desktop\nitrofleet\venv\lib\site-packages\django\db\models\sql\compiler.py", line 1361, in execute_sql
cursor.execute(sql, params)
File "C:\Users\DRT\Desktop\nitrofleet\venv\lib\site-packages\django\db\backends\utils.py", line 103, in execute
return super().execute(sql, params)
File "C:\Users\DRT\Desktop\nitrofleet\venv\lib\site-packages\django\db\backends\utils.py", line 67, in execute
return self._execute_with_wrappers(
File "C:\Users\DRT\Desktop\nitrofleet\venv\lib\site-packages\django\db\backends\utils.py", line 80, in _execute_with_wrappers
return executor(sql, params, many, context)
File "C:\Users\DRT\Desktop\nitrofleet\venv\lib\site-packages\django\db\backends\utils.py", line 84, in _execute
with self.db.wrap_database_errors:
File "C:\Users\DRT\Desktop\nitrofleet\venv\lib\site-packages\django\db\utils.py", line 91, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
File "C:\Users\DRT\Desktop\nitrofleet\venv\lib\site-packages\django\db\backends\utils.py", line 89, in _execute
return self.cursor.execute(sql, params)
File "C:\Users\DRT\Desktop\nitrofleet\venv\lib\site-packages\django\db\backends\sqlite3\base.py", line 477, in execute
return Database.Cursor.execute(self, query, params)
Exception Type: OperationalError at /admin/maintenance/component/
Exception Value: no such table: maintenance_component