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

181
Views
pasando latitud y longitud de javascript o html a la vista de Django

Cómo pasar lat y lng a la vista de Django sin hacer clic en el botón

 pos = {lat: position.coords.latitude, lng: position.coords.longitude,};

Estoy trabajando en un proyecto de Django y tratando de obtener la ubicación actual del usuario. Tengo una función javascript que devuelve la latitud y la longitud, pero no puedo pasarlas a Django como variables para guardarlas o hacer algo con ellas. Estoy usando la API de Google Maps.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

** Puede usar el parámetro de vista de Django para pasar algunos datos a sus vistas: **

vistas.py

 def coordinates(request, lat, long): // You may try to convert the lat and long variables // in the good type, i suppose here they are float my_lat, my_long = Float(lat), Float(long) context = {'lat': my_lat, 'long': my_long} return render(request, 'coordinates.html', context)

urls.py

 from app_name import views path('coordinates/<str:lat>/<str:long>/', views.coordinates, name='coordinates')

NB: paso el lat y long aquí como una cadena, pero en la vista los convierto con Float(). Y este es un ejemplo de URL: http://localhost:8000/coordinates/3.45/4.57

.html

 <section> The latitude is : {{ lat }} <br> The longitude is : {{ long }} </section>
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!