How to override the default wagtail page slug

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 ?


Solution 1:

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.