etianen / django-watson

Full-text multi-table search application for Django. Easy to install and use, with good performance.
BSD 3-Clause "New" or "Revised" License
1.21k stars 129 forks source link

Add app_name to be compatible with Django 2. #234

Closed ryokamiya closed 6 years ago

ryokamiya commented 6 years ago

Namespace in urls.py is not sufficient since Django 2.

etianen commented 6 years ago

Can you point me to some documentation on this?

The tests pass with Django 2.0, as it stands.

amureki commented 6 years ago

I did some testing and the current django-watson version was working fine in Django 2.0 without this change.

@ryokamiya if you could provide an example or error log, that would be great.

ryokamiya commented 6 years ago

Sure.. hmm it is failing to start for me with Django 2.0 without the change.

Reference docs:

Deprecated since version 1.9:

  • Support for the app_name argument is deprecated and will be removed in Django 2.0. Specify the app_name as explained in URL namespaces and included URLconfs instead.
  • Support for passing a 3-tuple is also deprecated and will be removed in Django 2.0. Pass a 2-tuple containing the pattern list and application namespace, and use the namespace argument instead.
  • Lastly, support for an instance namespace without an application namespace has been deprecated and will be removed in Django 2.0. Specify the application namespace or remove the instance namespace.

Error I'm having:

Traceback (most recent call last):
  File "./manage.py", line 22, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python3.6/site-packages/django/core/management/__init__.py", line 371, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python3.6/site-packages/django/core/management/__init__.py", line 365, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python3.6/site-packages/django/core/management/base.py", line 288, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/usr/local/lib/python3.6/site-packages/django/core/management/base.py", line 332, in execute
    self.check()
  File "/usr/local/lib/python3.6/site-packages/django/core/management/base.py", line 364, in check
    include_deployment_checks=include_deployment_checks,
  File "/usr/local/lib/python3.6/site-packages/django/core/management/base.py", line 351, in _run_checks
    return checks.run_checks(**kwargs)
  File "/usr/local/lib/python3.6/site-packages/django/core/checks/registry.py", line 73, in run_checks
    new_errors = check(app_configs=app_configs)
  File "/usr/local/lib/python3.6/site-packages/django/core/checks/urls.py", line 40, in check_url_namespaces_unique
    all_namespaces = _load_all_namespaces(resolver)
  File "/usr/local/lib/python3.6/site-packages/django/core/checks/urls.py", line 57, in _load_all_namespaces
    url_patterns = getattr(resolver, 'url_patterns', [])
  File "/usr/local/lib/python3.6/site-packages/django/utils/functional.py", line 36, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/usr/local/lib/python3.6/site-packages/django/urls/resolvers.py", line 536, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "/usr/local/lib/python3.6/site-packages/django/utils/functional.py", line 36, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/usr/local/lib/python3.6/site-packages/django/urls/resolvers.py", line 529, in urlconf_module
    return import_module(self.urlconf_name)
  File "/usr/local/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/usr/src/app/guildary/urls.py", line 26, in <module>
    url(r"^search/", include("watson.urls", namespace="watson")),
  File "/usr/local/lib/python3.6/site-packages/django/urls/conf.py", line 39, in include
    'Specifying a namespace in include() without providing an app_name '
django.core.exceptions.ImproperlyConfigured: Specifying a namespace in include() without providing an app_name is not supported. Set the app_name attribute in the included module, or pass a 2-tuple containing the list of patterns and app_name instead.

Please also note that with the app_name in watson/urls.py, the following also works fine without namespace.

    url(r"^search/", include("watson.urls")),
etianen commented 6 years ago

I understand, thanks.

I've just merged this into master. Let me know if it's working for you.

ryokamiya commented 6 years ago

Hi, it works good to me. Thanks!

etianen commented 6 years ago

Released as django-watson 1.5.1

On 9 February 2018 at 14:12, Ryoichiro Kamiya notifications@github.com wrote:

Hi, it works good to me. Thanks!

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/etianen/django-watson/pull/234#issuecomment-364444271, or mute the thread https://github.com/notifications/unsubscribe-auth/AAJFCG55kRgsg_uFpf-IlmqN3zTGLW9iks5tTFJfgaJpZM4R2zxX .