Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

195
Views
Cree una base de datos falsa para probar la API con wagtail

Necesito crear algunas pruebas contra mis API. Las API usan páginas wagtail y me entregan el contenido de ellas. Estoy en el punto de crear la base de datos para las pruebas, pero no puedo crear páginas de wagtail, porque siempre obtengo

 ValidationError: {'path': [u'This field cannot be blank.'], 'depth': [u'This field cannot be null.']}

¿Cómo puedo hacerlo? ¿Tengo que crear todo el sitio desde la raíz hasta el árbol?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

depth - es un nivel de anidamiento. La página ROOT tiene el nivel 1, la página principal tiene el nivel 2. Obviamente, solo 1 página puede estar en el primer y segundo nivel.

path - este es un valor específico, que aún no he entendido.

La página ROOT ( depth = 1) tiene esta ruta: 0001 ,

La página principal en el segundo nivel de anidamiento ( depth = 2) tiene la ruta 00010001 .

La primera página en el tercer nivel de anidamiento ( depth = 3) tiene la ruta 000100010001

No puedo garantizar que te dé un consejo que funcione, ya que lo hice durante mucho tiempo, pero si quieres generar páginas falsas al mismo nivel de anidamiento, solo necesitas cambiar la ruta, agregando + 1 a la último dígito, y dejando la profundidad sin cambios.

Por ejemplo:

 from yourapp.models import FakePage k = 1 for i in range(5): k = k + 1 page = FakePage( title = ('faketitle{}').format(k), path = ('{0:04}').format(k) depth = 3, ) page.save()

Pero hay una mejor manera:

 from wagtail.wagtailcore.models import Page from yourapp.models import FakePage pages = Page.objects.all() # Get all pages page = Page.objects.get(pk=3) # For example, take a page with pk = 3 fakepage = FakePage(title='fakepage title') # Create the desired page page.add_child(instance=fakepage) # Add children page to the parrent page

En este caso, no necesita preocuparse por la profundidad y el camino.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!