django-check-seo icon indicating copy to clipboard operation
django-check-seo copied to clipboard

Problem when using django check seo for django 3+ sites

Open corentinbettiol opened this issue 2 years ago • 3 comments

Here's the problem:

https://github.com/kapt-labs/django-check-seo/blob/master/django_check_seo/urls.py#L11

maybe we should check not version.startswith('1') ?

corentinbettiol avatar Jul 28 '22 12:07 corentinbettiol

I support, I also faced such a problem, me version Django 4.0.7

version.startswith("4")

I corrected this point, but there is a problem here

    for module_name in sys.modules:
        if (
            "django_check_seo.checks_list." in module_name
            and module_name not in python_2_compatibility_array
        ) or (module_name.startswith("checks_list.")):
            module = importlib.import_module(module_name)
            get_module_order = getattr(module, "importance")

            # get the importance
            modules_order.append([module, get_module_order()])
 modules_order.append([module, get_module_order()])

The error I get

Traceback (most recent call last): File "\venv\lib\site-packages\django\core\handlers\exception.py", line 55, in inner response = get_response(request) File "\venv\lib\site-packages\django\core\handlers\base.py", line 197, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "\venv\lib\site-packages\django\contrib\auth\decorators.py", line 23, in _wrapped_view return view_func(request, *args, **kwargs) File "\venv\lib\site-packages\django\views\generic\base.py", line 84, in view return self.dispatch(request, *args, **kwargs) File "\venv\lib\site-packages\django\views\generic\base.py", line 119, in dispatch return handler(request, *args, **kwargs) File "\venv\lib\site-packages\django\views\generic\base.py", line 185, in get context = self.get_context_data(**kwargs) File "\venv\lib\site-packages\django_check_seo\views.py", line 32, in get_context_data launch_checks.launch_checks(page_stats) File "\venv\lib\site-packages\django_check_seo\checks_list\launch_checks.py", line 59, in launch_checks getattr(module[0], "run")(site) File "\venv\lib\site-packages\django_check_seo\checks_list\check_keyword_url.py", line 57, in run url_path = urlparse(site.full_url, "/").path File "C:\Users\USER\AppData\Local\Programs\Python\Python39\lib\urllib\parse.py", line 389, in urlparse url, scheme, _coerce_result = _coerce_args(url, scheme) File "C:\Users\USER\AppData\Local\Programs\Python\Python39\lib\urllib\parse.py", line 122, in _coerce_args raise TypeError("Cannot mix str and non-str arguments") TypeError: Cannot mix str and non-str arguments Internal Server Error: /test/django-check-seo/ Traceback (most recent call last): File "\venv\lib\site-packages\django\core\handlers\exception.py", line 55, in inner response = get_response(request) File "\venv\lib\site-packages\django\core\handlers\base.py", line 197, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "\venv\lib\site-packages\django\contrib\auth\decorators.py", line 23, in _wrapped_view return view_func(request, *args, **kwargs) File "\venv\lib\site-packages\django\views\generic\base.py", line 84, in view return self.dispatch(request, *args, **kwargs) File "\venv\lib\site-packages\django\views\generic\base.py", line 119, in dispatch return handler(request, *args, **kwargs) File "\venv\lib\site-packages\django\views\generic\base.py", line 185, in get context = self.get_context_data(**kwargs) File "\venv\lib\site-packages\django_check_seo\views.py", line 32, in get_context_data launch_checks.launch_checks(page_stats) File "\venv\lib\site-packages\django_check_seo\checks_list\launch_checks.py", line 59, in launch_checks getattr(module[0], "run")(site) File "\venv\lib\site-packages\django_check_seo\checks_list\check_keyword_url.py", line 57, in run url_path = urlparse(site.full_url, "/").path File "C:\Users\USER\AppData\Local\Programs\Python\Python39\lib\urllib\parse.py", line 389, in urlparse url, scheme, _coerce_result = _coerce_args(url, scheme) File "C:\Users\USER\AppData\Local\Programs\Python\Python39\lib\urllib\parse.py", line 122, in _coerce_args raise TypeError("Cannot mix str and non-str arguments") TypeError: Cannot mix str and non-str arguments

odi1n avatar Aug 16 '22 19:08 odi1n

I fixed the startswith problem. I will look your problem when I have more time :)

corentinbettiol avatar Sep 21 '22 16:09 corentinbettiol

@odi1n Hi, I can't replicate your problem, can I close the issue?

corentinbettiol avatar Jan 25 '24 12:01 corentinbettiol