Skip to content

Improve "Setting up URLconf" section in installation docs #1349

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

Merged
merged 1 commit into from
Oct 1, 2020
Merged

Improve "Setting up URLconf" section in installation docs #1349

merged 1 commit into from
Oct 1, 2020

Conversation

jdufresne
Copy link
Contributor

@jdufresne jdufresne commented Sep 27, 2020

Remove the "if settings.DEBUG" guard. This guard is not necessary and
leads to several edge cases in local development setups.

This is not necessary as all views are guarded by the
require_show_toolbar decorator which uses the SHOW_TOOLBAR_CALLBACK
setting. This setting is already capable of enabling/disabling the
across the application when DEBUG is False. By default, when DEBUG is
False, these views return a 404 response.

By having the URLs always available, the MIDDLEWARE setting also doesn't
need special handling when DEBUG is False, simplifing the overall
configuration. An application should be able to reliably reverse URLs
regardless of the status of DEBUG.

Fixes #1035
Fixes #1043
Fixes #1332

@@ -43,16 +43,16 @@ If you're upgrading from a previous version, you should review the
Setting up URLconf
------------------

Add the Debug Toolbar's URLs to your project's URLconf as follows::
Add the Debug Toolbar's URLs to your project's URLconf as the last entry::
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason for specifying "the last entry"?

feincms3 uses a catch-all pattern at the end (https://feincms3.readthedocs.io/en/latest/build-your-cms.html#views-and-urls), Wagtail too (https://github.com/wagtail/wagtail/blob/master/wagtail/core/urls.py)

Adding the debug toolbar after those catch-all patterns will not work.
Anyone using a CMS (feincms3 or wagtail

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. It doesn't need to strictly be the last entry. I've removed that wording in the latest revision.

Remove the "if settings.DEBUG" guard. This guard is not necessary and
leads to several edge cases in local development setups.

This is not necessary as all views are guarded by the
require_show_toolbar decorator which uses the SHOW_TOOLBAR_CALLBACK
setting. This setting is already capable of enabling/disabling across
the application when DEBUG is False. By default, when DEBUG is False,
these views return a 404 response.

By having the URLs always available, the MIDDLEWARE setting also doesn't
need special handling when DEBUG is False, simplifing the overall
configuration. An application should be able to reliably reverse URLs
regardless of the status of DEBUG.

Fixes #1035
Fixes #1043
Fixes #1332
@matthiask matthiask merged commit bd365b8 into django-commons:master Oct 1, 2020
@matthiask
Copy link
Member

Thanks!

@jdufresne jdufresne deleted the install branch October 2, 2020 09:51
adamchainz added a commit to adamchainz/django-debug-toolbar that referenced this pull request Nov 15, 2021
The import of settings is no longer required after django-commons#1349
matthiask pushed a commit that referenced this pull request Nov 15, 2021
The import of settings is no longer required after #1349
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants