modlinltd/django-advanced-filters

Suggestion: Import module for use in url include

Opened this issue · 0 comments

Hello! Thanks for creating this module. It is quite useful.

In the README instructions, it says

Add url(r'^advanced_filters/', include('advanced_filters.urls')) to your project's urlconf.

What do you think about importing the module and referencing it instead?

Using 'advanced_filters.urls' simply as a string makes it harder for people and linters to detect that the project is being used.
If you are e.g. cleaning up your requirements.txt, this usage might get missed, since it only exists inside the string. And the name 'advanced_filters' inside the string does not match the module name 'django-advanced-filters'.

Instead, what do you think about using this module via an import?

 # in urls.py
 from advanced_filters import urls as advanced_filters_urls

 # ...
 urlpatterns = [
 # ...
     url(r"^advanced_filters/", include(advanced_filters_urls)),
 # ...
 ]

This way, linters can better detect that any codebase is using the module. And it is more obvious where and how we use it.
This would make it harder to miss.

I could send a patch to update the README.md if that's helpful.
Thanks!