Wagtail redirect max length too short

Wagtail redirect max length too short



Our migration into Wagtail involves creating redirects for very long urls e.g. urls in Arabic. These do not seem to be supported by the Wagtail redirects system. Any workarounds for this?



Migration script error:


django.db.utils.DataError: value too long for type character varying(255)



Database console error:


db_1 | 2018-08-24 13:19:06.000 UTC [134] ERROR: value too long for type character varying(255)
db_1 | 2018-08-24 13:19:06.000 UTC [134] STATEMENT: INSERT INTO "wagtailredirects_redirect" ("old_path", "site_id", "is_permanent", "redirect_page_id", "redirect_link") VALUES ('https://www.opendemocracy.net/5050/atiaf-zaid-alwazir/%D9%88%D9%85%D8%A7-%D9%8A%D8%B2%D8%A7%D9%84-%D8%A7%D9%84%D8%B7%D8%B1%D9%8A%D9%82-%D8%B7%D9%88%D9%8A%D9%84%D8%A7-%E2%80%93-%D8%A8%D9%82%D9%84%D9%85-%D8%A3%D8%B7%D9%8A%D8%A7%D9%81-%D8%B2%D9%8A%D8%AF-%D8%A7%D9%84%D9%88%D8%B2%D9%8A%D8%B1', 1, true, 9528, '') RETURNING "wagtailredirects_redirect"."id"



(note: even removing the domain from the url still leaves us with a utf-8 string of 257, which is too long)





Hopefully this doesn't sound too glib - but you'll likely have to modify the base Wagtail code - up the max length, there's likely somewhere a redirects model.
– user10261970
Aug 24 at 15:36





Would strongly prefer not to run a forked version of Wagtail. But this is an option, thank you.
– KindOfGuy
Aug 24 at 16:44





I would suggest you open this as an issue on the Wagtail issue tracker. This length limit looks a bit arbitrary, and I'm sure you could make the case for it to be raised or removed.
– Thibaud Colas
Aug 25 at 19:25





The current limit is set at github.com/wagtail/wagtail/blob/master/wagtail/contrib/… Interestingly, the limit in Django's redirect app is even lower: github.com/django/django/blob/master/django/contrib/redirects/… Django requires a max_length argument for Charfields. There's an 8 year old discussion about this: code.djangoproject.com/ticket/14094 I guess there are two options for dealing with this in Wagtail: increase the max_length, or convert it to a TextField, which may have performance implications on some backends?
– tomd
Aug 26 at 14:19


max_length


Charfield





@KindOfGuy yes I think so. Keeping CharField and increasing max_length to 500 feels like a flawed but safe approach. Feel free to discuss with me and others on Slack at wagtail.io/slack
– tomd
Aug 28 at 20:44


CharField









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

Edmonton

Crossroads (UK TV series)