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

99
Views
¿Es posible redirigir a otra página con la identificación de la página anterior?

ingrese la descripción de la imagen aquí

Entonces, como puede ver en una página, tengo el nombre de la tienda y su dirección. Además, tengo una función de edición en views.py:

 def update_shop(request, id): context = {} # * fetch the object related to passed id obj_shop = get_object_or_404(VideoLibrary, id=id) # * pass the object as instance in form form_shop = VideoLibraryForm(request.POST or None, instance=obj_shop) # * save the data from the form and # * redirect to detail_view if form_shop.is_valid(): form_shop.save() return HttpResponseRedirect('/main/') context['form_shop'] = form_shop return render(request, 'update/update_shop.html', context)

urls.py:

 ... path('list_view/', views.list_view, name='list_view'), path('shop/<id>/update', views.update_shop, name='update_shop'),

La imagen está en una página diferente ('lilst_view') y el problema es que necesito colocar un botón en esta página y redirigir a la página de actualización para editar ciertos nombres de tiendas, por ejemplo. Para hacer esto, supongo que necesito obtener de alguna manera la identificación del objeto. ¿Alguien sabe cómo hacerlo?

lista_vista.html

 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>Document</title> </head> <body> <div class="main"> {% for data in library_dataset %} Shop name: <br /> <br /> {{ data.shop_name }} <br /> {{ data.adress }} <br /> {% endfor %} </div> </body> </html>

views.py (def list_view):

 def list_view(request): context = {} context['library_dataset'] = VideoLibrary.objects.all() return render(request, 'app/list_view.html', context)
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

#vista_lista.html

 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>Document</title> </head> <body> <div class="main"> {% for data in library_dataset %} Shop name: <br /> <br /> {{ data.shop_name }} <br /> {{ data.adress }} <br /> <td><a href="{% url 'update_shop' data.id %}"> <button type="button" class="btn btn-primary">Edit Shop Details</button> </a> </td> {% endfor %} </div> </body> </html>
about 4 years ago · Juan Pablo Isaza Report

0

en este caso puedes hacerlo en Django simplemente usando el método redirect() con parámetros, por ejemplo

 return redirect('some-view-name', parameter_name='par_value')

y en una etiqueta poner <a href={% url 'view_name' desired_id %}

about 4 years ago · Juan Pablo Isaza 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!