kapt-labs / django-check-seo

Django Check SEO will check the SEO aspects of your site for you, and will provide advice in case of problems. Compatible with Django & Django-CMS!
GNU General Public License v3.0
154 stars 12 forks source link

Problem when using django check seo for django 3+ sites #51

Open corentinbettiol opened 2 years ago

corentinbettiol commented 2 years ago

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') ?

odi1n commented 2 years ago

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

corentinbettiol commented 1 year ago

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

corentinbettiol commented 7 months ago

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