Upgrade z Django 1.8 do 3.2.20

0

dostałem do upgrade aplikację Django, działającą w pythonie 2.7 i django 1.8.19, użyłem pyugrade i django upgrade, poczytałem trochę o zależnościach, zainstalowałem je w nowym środowisku wirtualnym i próbuję uruchomić serwer django, niestety się nie udaje, dostaję błąd:

Exception in thread django-main-thread:
Traceback (most recent call last):
  File "/usr/lib/python3.10/threading.py", line 1016, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.10/threading.py", line 953, in run
    self._target(*self._args, **self._kwargs)
  File "/home/tomek/www/upgraded2/app/env-upg/lib/python3.10/site-packages/django/utils/autoreload.py", line 64, in wrapper
    fn(*args, **kwargs)
  File "/home/tomek/www/upgraded2/app/env-upg/lib/python3.10/site-packages/django/core/management/commands/runserver.py", line 118, in inner_run
    self.check(display_num_errors=True)
  File "/home/tomek/www/upgraded2/app/env-upg/lib/python3.10/site-packages/django/core/management/base.py", line 419, in check
    all_issues = checks.run_checks(
  File "/home/tomek/www/upgraded2/app/env-upg/lib/python3.10/site-packages/django/core/checks/registry.py", line 76, in run_checks
    new_errors = check(app_configs=app_configs, databases=databases)
  File "/home/tomek/www/upgraded2/app/env-upg/lib/python3.10/site-packages/django/core/checks/urls.py", line 40, in check_url_namespaces_unique
    all_namespaces = _load_all_namespaces(resolver)
  File "/home/tomek/www/upgraded2/app/env-upg/lib/python3.10/site-packages/django/core/checks/urls.py", line 57, in _load_all_namespaces
    url_patterns = getattr(resolver, 'url_patterns', [])
  File "/home/tomek/www/upgraded2/app/env-upg/lib/python3.10/site-packages/django/utils/functional.py", line 48, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/home/tomek/www/upgraded2/app/env-upg/lib/python3.10/site-packages/django/urls/resolvers.py", line 602, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "/home/tomek/www/upgraded2/app/env-upg/lib/python3.10/site-packages/django/utils/functional.py", line 48, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/home/tomek/www/upgraded2/app/env-upg/lib/python3.10/site-packages/django/urls/resolvers.py", line 595, in urlconf_module
    return import_module(self.urlconf_name)
  File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/home/tomek/www/upgraded2/app/epaszport/urls.py", line 7, in <module>
    from cmms.api import *
  File "/home/tomek/www/upgraded2/app/cmms/api.py", line 5, in <module>
    from cmms.models import Genre, Make, Device, Mileage, Ticket, Service
  File "/home/tomek/www/upgraded2/app/cmms/models.py", line 17, in <module>
    from crm.models import Invoice, Contractor, Location, CostCentre, Hospital, UserProfile
  File "/home/tomek/www/upgraded2/app/crm/models.py", line 6, in <module>
    from django.contrib.auth.models import AbstractUser
  File "/home/tomek/www/upgraded2/app/env-upg/lib/python3.10/site-packages/django/contrib/auth/models.py", line 5, in <module>
    from django.contrib.contenttypes.models import ContentType
  File "/home/tomek/www/upgraded2/app/env-upg/lib/python3.10/site-packages/django/contrib/contenttypes/models.py", line 133, in <module>
    class ContentType(models.Model):
  File "/home/tomek/www/upgraded2/app/env-upg/lib/python3.10/site-packages/django/db/models/base.py", line 113, in __new__
    raise RuntimeError(
RuntimeError: Model class django.contrib.contenttypes.models.ContentType doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS.

W INSTALLED_APPS oczywiście mam django.contrib.contenttype,:

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.messages',
    'django_comments',
    'django.contrib.staticfiles',
    'django.contrib.contenttypes',
    'crm.apps.CrmConfig',
    'guardian',
    'cmms.apps.CmmsConfig',
    'tastypie',
    'dane.apps.DaneConfig',
    'utils.apps.CoursesConfig',
    'kombu.transport',
    'django_extensions',
    'wkhtmltopdf',
    'ckeditor',
    'csvimport.app.CSVImportConf',
    'reminders.apps.RemindersConfig',
    'simple_history',
    'sendfile',
    'data_import.apps.DataImportConfig',
]

próbowałem wszystkiego co znalazłem w sieci, pytałem chata GPT, niestety nic nie dało, pycharm nic nie podkreśla... w virtuaenv mam pythona 3.10 i odpowiednio dobrane requirementsy... Ktoś jest mnie w stanie naprowadzić?

0

To co mozesz zrobić to przeniesc django.contrib.contenttypes na samą górę i zobaczyć czy błąd zniknie.

0

próbowałem,nic, chat gpt powiedział że w urls.py trzeba zastąpić funkcję patterns, funkcjami path i re_path, spróbuję w poniedziałek

0

nic to nie dało, stwierdziłem, że najpierw spróbuję zupgradeować to django do ostatniej jedynki (1.11.29), też nie ruszył projekt, po zmianie kolejności importów w kilku pliikach i ugradzie składni pythona do 3 dostaję teraz taki błąd:

Exception ignored in thread started by: <function check_errors.<locals>.wrapper at 0x7fefacb441f0>
Traceback (most recent call last):
  File "/home/tomek/www/upgrade-epaszport/epaszport-master-pyupgrade-1.11/venv-upg/lib/python3.8/site-packages/django/utils/autoreload.py", line 228, in wrapper
    fn(*args, **kwargs)
  File "/home/tomek/www/upgrade-epaszport/epaszport-master-pyupgrade-1.11/venv-upg/lib/python3.8/site-packages/django/core/management/commands/runserver.py", line 124, in inner_run
    self.check(display_num_errors=True)
  File "/home/tomek/www/upgrade-epaszport/epaszport-master-pyupgrade-1.11/venv-upg/lib/python3.8/site-packages/django/core/management/base.py", line 356, in check
    all_issues = self._run_checks(
  File "/home/tomek/www/upgrade-epaszport/epaszport-master-pyupgrade-1.11/venv-upg/lib/python3.8/site-packages/django/core/management/base.py", line 346, in _run_checks
    return checks.run_checks(**kwargs)
  File "/home/tomek/www/upgrade-epaszport/epaszport-master-pyupgrade-1.11/venv-upg/lib/python3.8/site-packages/django/core/checks/registry.py", line 81, in run_checks
    new_errors = check(app_configs=app_configs)
  File "/home/tomek/www/upgrade-epaszport/epaszport-master-pyupgrade-1.11/venv-upg/lib/python3.8/site-packages/django/core/checks/urls.py", line 16, in check_url_config
    return check_resolver(resolver)
  File "/home/tomek/www/upgrade-epaszport/epaszport-master-pyupgrade-1.11/venv-upg/lib/python3.8/site-packages/django/core/checks/urls.py", line 26, in check_resolver
    return check_method()
  File "/home/tomek/www/upgrade-epaszport/epaszport-master-pyupgrade-1.11/venv-upg/lib/python3.8/site-packages/django/urls/resolvers.py", line 256, in check
    for pattern in self.url_patterns:
  File "/home/tomek/www/upgrade-epaszport/epaszport-master-pyupgrade-1.11/venv-upg/lib/python3.8/site-packages/django/utils/functional.py", line 35, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/home/tomek/www/upgrade-epaszport/epaszport-master-pyupgrade-1.11/venv-upg/lib/python3.8/site-packages/django/urls/resolvers.py", line 407, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "/home/tomek/www/upgrade-epaszport/epaszport-master-pyupgrade-1.11/venv-upg/lib/python3.8/site-packages/django/utils/functional.py", line 35, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/home/tomek/www/upgrade-epaszport/epaszport-master-pyupgrade-1.11/venv-upg/lib/python3.8/site-packages/django/urls/resolvers.py", line 400, in urlconf_module
    return import_module(self.urlconf_name)
  File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 843, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/tomek/www/upgrade-epaszport/epaszport-master-pyupgrade-1.11/app/epaszport/urls.py", line 6, in <module>
    from utils.views import PDFPreview, PDFGenerate, GenerateXLSPreview, GenerateXLS, PDFGenerateDirectly
  File "/home/tomek/www/upgrade-epaszport/epaszport-master-pyupgrade-1.11/app/utils/views.py", line 20, in <module>
    from cmms.models import Service, Document, Device
  File "/home/tomek/www/upgrade-epaszport/epaszport-master-pyupgrade-1.11/app/cmms/models.py", line 185, in <module>
    class Make(models.Model):
  File "/home/tomek/www/upgrade-epaszport/epaszport-master-pyupgrade-1.11/venv-upg/lib/python3.8/site-packages/django/db/models/base.py", line 318, in __new__
    new_class._prepare()
  File "/home/tomek/www/upgrade-epaszport/epaszport-master-pyupgrade-1.11/venv-upg/lib/python3.8/site-packages/django/db/models/base.py", line 375, in _prepare
    class_prepared.send(sender=cls)
  File "/home/tomek/www/upgrade-epaszport/epaszport-master-pyupgrade-1.11/venv-upg/lib/python3.8/site-packages/django/dispatch/dispatcher.py", line 191, in send
    return [
  File "/home/tomek/www/upgrade-epaszport/epaszport-master-pyupgrade-1.11/venv-upg/lib/python3.8/site-packages/django/dispatch/dispatcher.py", line 192, in <listcomp>
    (receiver, receiver(signal=self, sender=sender, **named))
  File "/home/tomek/www/upgrade-epaszport/epaszport-master-pyupgrade-1.11/venv-upg/lib/python3.8/site-packages/simple_history/models.py", line 93, in finalize
    history_model = self.create_history_model(sender, inherited)
  File "/home/tomek/www/upgrade-epaszport/epaszport-master-pyupgrade-1.11/app/utils/models.py", line 252, in create_history_model
    type(str(name), self.bases, attrs))
  File "/home/tomek/www/upgrade-epaszport/epaszport-master-pyupgrade-1.11/venv-upg/lib/python3.8/site-packages/django/db/models/base.py", line 115, in __new__
    raise RuntimeError(
RuntimeError: Model class cmms.models.HistoricalMake doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS.

nie tworzy się model historyczny dla pierwszego możliwego modelu , simple-history zupgradeowałem do wersji 1.9.1, podobno działa z django 1.11. Ktoś jest w stanie pomóc?

0

Ok, to jeszcze tak. Masz w INSTALLED_APPS zarejestrowanych kilka aplikacji w stylu foo.apps.fooCobfig. Masz w nich zależności jedna do drugiej pewnie. Musisz je ustawić w odpowiedniej kolejności, tak jak one z siebie korzystają.

1 użytkowników online, w tym zalogowanych: 0, gości: 1