Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

173
Visualizações
Modify slug for every page of model on wagtail

I am trying to create a custom slug for every page of a specific Page model on Wagtail. I have been looking into and tried the RoutablePageMixin examples, but that seems to modify the url structure, not the slug itself.

Here is what I am looking to do:

Current page title: About Django

current page slug: about-django

page title I want: About Django

page slug I want: awesome-things-about-django

I looked at creating route method, but that didn't seem to modify the slug. Is there any way to prepend something onto your slug? I understand I can do this manually, but would prefer for it to happen automatically.

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

One possibility for making automatic updates to pages on save is to override the full_clean method:

class MyPage(Page):

    # ...

    def full_clean(self, *args, **kwargs):
        # first call the built-in cleanups (including default slug generation)
        super(MyPage, self).full_clean(*args, **kwargs)

        # now make your additional modifications
        if not self.slug.startswith('awesome'):
            self.slug = "awesome-%s" % self.slug
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda