0

I'm trying to make a wagtail pages for the astrologer based on category, country and city. And my url's are:

  https//localhost:8080/<category>
  https//localhost:8080/<category>/<country>
  https//localhost:8080/<category><country>/<city>

If I am trying to save the url with '/' forward slash then it removing the '/' form the slug and saving it as a string.

Ex: <category><country>/<city> to categorycountrycity

So Is it possible to override the wagtail default page slug type 'SlugField' to 'CharField'. or is there any other solution ?

Amitjoc
  • 83
  • 4
  • 9
  • The slash will not be part of the slug. Why don't you define `///`? – Willem Van Onsem Jan 14 '22 at 11:31
  • if you use ``, then `category` will "eat" all the characters except the last one, and then `country` will get the last character, so `cat1usa` will assign `cat1us` to `category`. – Willem Van Onsem Jan 14 '22 at 11:33
  • What you're describing doesn't sound like standard Wagtail behaviour at all - ordinary Wagtail pages always use slashes to separate path elements, and there's no option to configure this. Are you using `RoutablePageMixin`? If so, please share your code. – gasman Jan 14 '22 at 12:15

1 Answers1

2

URLs are tightly tied to the page tree, and the slug is just the part which identifies the page at that level, rather than any parent levels. So if you want https://localhost:8080/<category>/<country>/<city>, you will need:

  • A page at https://localhost:8080/<category>/, whose slug is just the name of the category
  • The above category page to have a child, with the slug of just the country (which will give it the URL https://localhost:8080/<category>/<country>/)
  • The country page to have a child page, with the slug of just the city name (which will give it the URL https://localhost:8080/<category>/<country>/<city>).

Need other cities, make more child pages under the "country" page. Need more countries, make more child pages under the "category" page. Need more categories, make more child pages under the root page.