Not Having a BASE_URL in settings.py break import when media is involved
AlanSwenson opened this issue · comments
Situation:
I have MEDIA_URL= '/events/media/'
in my settings for s3
so it triggers
wagtail-transfer/wagtail_transfer/field_adapters.py
Lines 172 to 175 in 4fd1ef2
But I dont have any BASE_URL
in settings and I don't see this mentioned in the Docs at all.
Not having it triggers an error, I have tried a few different settings and it gets past the error but then after the content download I get DB integrity errors which makes it looks like wagtail is trying to transfer objects that have nothing to do with wagtail at all from the remote DB.
Here is an example.
IntegrityError at /cms/wagtail-transfer/import/
duplicate key value violates unique constraint "django_content_type_app_label_model_76bd3d3b_uniq"
DETAIL: Key (app_label, model)=(events, pointofinterest) already exists.
Soooo....What do I set for BASE_URL?
For reference, if I import a page with no media there is not problems at all.
Thanks in advance.
Hi @AlanSwenson - I hit a similar issue and realised I needed to explicitly set settings.MEDIA_URL
to point to the hostname of my S3 bucket (ie, https://stevesbucketofthings.s3.amazonaws.com/
, not a relative path).
Setting this meant that the field adapter skips the block at L172, so does not try to build a relative/local-filesystem path for the S3-hosted file (which makes sense, because if the file is in S3, there is no local path to it)
While that might not work for your glitch, I thought it worth sharing because if your file is in S3, lines 172-175 shouldn't be being called, I think
Thanks @stevejalim for the tip. It didn't fix the issue but Ill keep it in my back pocket incase I get the issue resolved and then this pops up later.
@AlanSwenson did you solve your issue?
@stevejalim I did not. Had to move on for now. But I would love to solve it so I don't have to copy/paste things in the future.
I'm having similar issues when importing a page that has an image (custom image model, i don't know if this changes anything). Images are just stored locally and i receive following error
django.db.utils.IntegrityError: duplicate key value violates unique constraint "django_content_type_app_label_model_76bd3d3b_uniq"
DETAIL: Key (app_label, model)=(wagtaildocs, document) already exists.
As of Wagtail 3.0 this setting (WAGTAILADMIN_BASE_URL) is documented, and #118 adds a meaningful error message if this is missing.