django app 에서 makemigrations 했을때, 테이블이 없다는 오류메시지가 나올때 처리방법.
(venv) D:\Python_Project\ipchaser\ipchaser>manage.py makemigrations chaser Traceback (most recent call last): File "D:\Python_Project\ipchaser\venv\lib\site-packages\django\db\backends\utils.py", line 86, in _execute return self.cursor.execute(sql, params) File "D:\Python_Project\ipchaser\venv\lib\site-packages\django\db\backends\mysql\base.py", line 74, in execute return self.cursor.execute(query, args) File "D:\Python_Project\ipchaser\venv\lib\site-packages\MySQLdb\cursors.py", line 209, in execute res = self._query(query) File "D:\Python_Project\ipchaser\venv\lib\site-packages\MySQLdb\cursors.py", line 315, in _query db.query(q) File "D:\Python_Project\ipchaser\venv\lib\site-packages\MySQLdb\connections.py", line 239, in query _mysql.connection.query(self, query) MySQLdb._exceptions.ProgrammingError: (1146, "Table 'ipchaser.tools_macvendors' doesn't exist") The above exception was the direct cause of the following exception: Traceback (most recent call last): File "D:\Python_Project\ipchaser\ipchaser\manage.py", line 21, in <module> main() File "D:\Python_Project\ipchaser\ipchaser\manage.py", line 17, in main execute_from_command_line(sys.argv) File "D:\Python_Project\ipchaser\venv\lib\site-packages\django\core\management\__init__.py", line 401, in execute_from_command_line utility.execute() File "D:\Python_Project\ipchaser\venv\lib\site-packages\django\core\management\__init__.py", line 395, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "D:\Python_Project\ipchaser\venv\lib\site-packages\django\core\management\base.py", line 328, in run_from_argv self.execute(*args, **cmd_options) File "D:\Python_Project\ipchaser\venv\lib\site-packages\django\core\management\base.py", line 366, in execute self.check() File "D:\Python_Project\ipchaser\venv\lib\site-packages\django\core\management\base.py", line 395, in check include_deployment_checks=include_deployment_checks, File "D:\Python_Project\ipchaser\venv\lib\site-packages\django\core\management\base.py", line 382, in _run_checks return checks.run_checks(**kwargs) File "D:\Python_Project\ipchaser\venv\lib\site-packages\django\core\checks\registry.py", line 72, in run_checks new_errors = check(app_configs=app_configs) File "D:\Python_Project\ipchaser\venv\lib\site-packages\django\core\checks\urls.py", line 13, in check_url_config return check_resolver(resolver) File "D:\Python_Project\ipchaser\venv\lib\site-packages\django\core\checks\urls.py", line 23, in check_resolver return check_method() File "D:\Python_Project\ipchaser\venv\lib\site-packages\django\urls\resolvers.py", line 407, in check for pattern in self.url_patterns: File "D:\Python_Project\ipchaser\venv\lib\site-packages\django\utils\functional.py", line 48, in __get__ res = instance.__dict__[self.name] = self.func(instance) File "D:\Python_Project\ipchaser\venv\lib\site-packages\django\urls\resolvers.py", line 588, in url_patterns patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module) File "D:\Python_Project\ipchaser\venv\lib\site-packages\django\utils\functional.py", line 48, in __get__ res = instance.__dict__[self.name] = self.func(instance) File "D:\Python_Project\ipchaser\venv\lib\site-packages\django\urls\resolvers.py", line 581, in urlconf_module return import_module(self.urlconf_name) File "C:\Users\Works\AppData\Local\Programs\Python\Python37\lib\importlib\__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1006, in _gcd_import File "<frozen importlib._bootstrap>", line 983, in _find_and_load File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 677, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 728, in exec_module File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed File "D:\Python_Project\ipchaser\ipchaser\ipchaser\urls.py", line 20, in <module> path('tools/', include('tools.urls')), File "D:\Python_Project\ipchaser\venv\lib\site-packages\django\urls\conf.py", line 34, in include urlconf_module = import_module(urlconf_module) File "C:\Users\Works\AppData\Local\Programs\Python\Python37\lib\importlib\__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1006, in _gcd_import File "<frozen importlib._bootstrap>", line 983, in _find_and_load File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 677, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 728, in exec_module File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed File "D:\Python_Project\ipchaser\ipchaser\tools\urls.py", line 2, in <module> from .views import DiffView, MacVenrorsView, WhoisSearch, DNSLookup File "D:\Python_Project\ipchaser\ipchaser\tools\views.py", line 23, in <module> class MacVenrorsView(View): File "D:\Python_Project\ipchaser\ipchaser\tools\views.py", line 26, in MacVenrorsView total = MacVendors.objects.count() File "D:\Python_Project\ipchaser\venv\lib\site-packages\django\db\models\manager.py", line 82, in manager_method return getattr(self.get_queryset(), name)(*args, **kwargs) File "D:\Python_Project\ipchaser\venv\lib\site-packages\django\db\models\query.py", line 397, in count return self.query.get_count(using=self.db) File "D:\Python_Project\ipchaser\venv\lib\site-packages\django\db\models\sql\query.py", line 517, in get_count number = obj.get_aggregation(using, ['__count'])['__count'] File "D:\Python_Project\ipchaser\venv\lib\site-packages\django\db\models\sql\query.py", line 502, in get_aggregation result = compiler.execute_sql(SINGLE) File "D:\Python_Project\ipchaser\venv\lib\site-packages\django\db\models\sql\compiler.py", line 1144, in execute_sql cursor.execute(sql, params) File "D:\Python_Project\ipchaser\venv\lib\site-packages\django\db\backends\utils.py", line 100, in execute return super().execute(sql, params) File "D:\Python_Project\ipchaser\venv\lib\site-packages\django\db\backends\utils.py", line 68, in execute return self._execute_with_wrappers(sql, params, many=False, executor=self._execute) File "D:\Python_Project\ipchaser\venv\lib\site-packages\django\db\backends\utils.py", line 77, in _execute_with_wrappers return executor(sql, params, many, context) File "D:\Python_Project\ipchaser\venv\lib\site-packages\django\db\backends\utils.py", line 86, in _execute return self.cursor.execute(sql, params) File "D:\Python_Project\ipchaser\venv\lib\site-packages\django\db\utils.py", line 90, in __exit__ raise dj_exc_value.with_traceback(traceback) from exc_value File "D:\Python_Project\ipchaser\venv\lib\site-packages\django\db\backends\utils.py", line 86, in _execute return self.cursor.execute(sql, params) File "D:\Python_Project\ipchaser\venv\lib\site-packages\django\db\backends\mysql\base.py", line 74, in execute return self.cursor.execute(query, args) File "D:\Python_Project\ipchaser\venv\lib\site-packages\MySQLdb\cursors.py", line 209, in execute res = self._query(query) File "D:\Python_Project\ipchaser\venv\lib\site-packages\MySQLdb\cursors.py", line 315, in _query db.query(q) File "D:\Python_Project\ipchaser\venv\lib\site-packages\MySQLdb\connections.py", line 239, in query _mysql.connection.query(self, query) django.db.utils.ProgrammingError: (1146, "Table 'ipchaser.tools_macvendors' doesn't exist")
당연히 테이블이 없는데, 테이블이 없다고 오류가 발생함.
project/urls.py 에, app 만들었을때 추가한 url을 주석처리하고 makemigrations 실행.
urlpatterns = [ # path('tools/', include('tools.urls')), # path('devmgr/', include('devmgr.urls')), # path('', include('chaser.urls')), # path('utils/', include('utils.urls')), path('admin/', admin.site.urls), path('accounts/', include('django.contrib.auth.urls')), ]
(venv) D:\Python_Project\ipchaser\ipchaser>manage.py makemigrations chaser Migrations for 'chaser': chaser\migrations\0001_initial.py - Create model Category - Create model DevInfo - Create model DropInfo - Create model History - Create model Memo - Create model SectorDesc - Create model Statistics - Create model MacIPinfo - Create model MacInfo - Create model ArpInfo
잘 만들어진다.