1

I added a django-leaflet map to display place markers. I couldn't display the markers as click events and send these to postgres/postgis database. I used django-leaflet forms to input the data. I wonder how I could display the place markers as well as send these to the backend along with other model fields.

{% load static %}
{% include 'base.html' %}
{% load leaflet_tags %}
<style>

    .leaflet-container {  /* all maps */
        width:  1400px;
        height: 800px;
        align-content: right;
    }
</style>
<html>
  <head>
   {% leaflet_js plugins="forms" %}
   {% leaflet_css plugins="forms" %}
  </head>


  <body>
    {% leaflet_map "map" callback="window.map_init_basic" %}
    <h2>Edit Apartment ID {{ Apartment.apt_id }}</h2>
    <h2>Edit Apartment Location {{ Apartment.location }}</h2>
    <form action="POST">
        {{ form }}
        <input type="submit"/>
    </form>
  </body>
</html>
<script type="text/javascript">
    window.addEventListener("map:init", function (e) {
        var detail = e.detail;

        L.marker([38.7578, 8.9806]).addTo(detail.map);

    }, false);
</script>
Kaleab Woldemariam
  • 2,567
  • 4
  • 22
  • 43

0 Answers0