torchbox / wagtail-grapple

A Wagtail app that makes building GraphQL endpoints a breeze!
https://wagtail-grapple.readthedocs.io/en/latest/
Other
153 stars 57 forks source link

`BASE_URL` needs replacing with `WAGTAILADMIN_BASE_URL` when using `wagtail>=3.0` #234

Open kbayliss opened 2 years ago

kbayliss commented 2 years ago

wagtail-grapple currently relys on a wagtail setting called BASE_URL, which is referenced in multiple places: https://github.com/torchbox/wagtail-grapple/search?q=BASE_URL

However, in wagtail==3.0 this is renamed to WAGTAILADMIN_BASE_URL.

From https://github.com/wagtail/wagtail/releases/tag/v3.0:

Rename the setting BASE_URL (undocumented) to WAGTAILADMIN_BASE_URL and add to documentation, BASE_URL will be removed in a future release.

dopry commented 2 years ago

I'm not sure that we necessarily want to replace all of those with WAGTAIL_ADMIN_BASEURL. That isn't necessarily the base URL for the site or the media.

kbayliss commented 2 years ago

@dopry Good thinking. Would that be better as a separate issue?

This issue is to address the small change required to support wagtail>=3.0, where BASE_URL has simply been renamed to WAGTAILADMIN_BASE_URL. Changing references from settings.BASE_URL to settings.WAGTAILADMIN_BASE_URL (when using wagtail>=3.0) doesn't alter any existing behaviour/functionality.

However, improving the URL handling across the project - as you've suggested - sounds sensible to me!

dopry commented 2 years ago

3.0 will still work with BASE_URL it's just deprecated. Removing the use of BASE_URL eliminates the need for this task and churn in the code. I opened a new ticket for the URL generation bugs.

kbayliss commented 2 years ago

If a project is using 3.0, they will likely have already removed BASE_URL as per the upgrade recommendations and replaced it with WAGTAILADMIN_BASE_URL, which will break wagtail-grapple unless they do something like:

BASE_URL = WAGTAILADMIN_BASE_URL = "http://..." which feels unnecessary.

Unless I'm missing something 🤔 ?

dopry commented 1 year ago

While it probably isn't ideal, I think having the weird config helps surface to developers we need to address url handling in grapple.

kbayliss commented 1 year ago

This is likely to cause further confusion, as Wagtail 5.0 states BASE_URL is no longer recognised and should be removed: https://docs.wagtail.org/en/latest/releases/5.0.html

(Speaking from experience, as I've just spent hours trying to work out why fetching images stopped working after upgrading to Wagtail 5.1 😅)

dopry commented 1 year ago

I feel like the wagtail documentation should maybe clarify that core no longer depends on BASE_URL and that contributed and 3rd Party modules may need it. Has there been any changes in core WRT to base urls for media?