Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
corentinbettiol opened this issue Jul 28, 2022 · 3 comments
Open

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

corentinbettiol opened this issue Jul 28, 2022 · 3 comments

Comments

@corentinbettiol
Copy link
Member

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
Copy link

odi1n commented Aug 16, 2022

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
Copy link
Member Author

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

@corentinbettiol
Copy link
Member Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants