makinacorpus / django-leaflet

Use Leaflet in your Django projects
GNU Lesser General Public License v3.0
713 stars 282 forks source link

ol is not defined #343

Closed Tobi-De closed 2 years ago

Tobi-De commented 2 years ago

I create a model with PointField from postgis, and in the form I'm using the leaflet wigdet but the map is not rendering and I'm getting in ly brower console, ol is not defined

class Location(TimeStampedModel):
    position = PointField(_("Position"))

class LocationForm(forms.ModelForm):
    class Meta:
        model = Location
        fields = ("name", "position")
        widgets = {"point": LeafletWidget()}
Gagaro commented 2 years ago

Did you include form.media?

Tobi-De commented 2 years ago

Did you include form.media?

I tried, same issue

{% extends "layouts/main.html" %}
{% load crispy_forms_filters %}
{% load leaflet_tags %}

{% leaflet_css plugins="forms" %}
{% leaflet_js plugins="forms" %}

{% block main_content %}
  <form method="post" action=".">
    {{ form|crispy }}
    <button type="submit">Submit</button>
  </form>
  {{ form.media }}
{% endblock %}
Bakhtiyar-Garashov commented 2 years ago

Maybe try to add it before your form html element ?

Tobi-De commented 2 years ago

Maybe try to add it before your form html element ?

Also tried that, the issue persist, I must be doing something wrong, I will review my setup