I try to add my form into an admin panel. I already have django-leaflet and it works normal via LeafletGeoAdmin.
But I need to add my form without a model.
I define a form:
from leaflet.forms.fields import PointField as PointFieldLL
from django import forms
class MarkerPostForm(forms.Form):
user_from = forms.CharField(label="User, marker's owner")
content = PointFieldLL()
A view:
@csrf_exempt
@alt_login_required
def post_marker_from_admin(request, v=None, user=None):
if user.is_staff is False:
return response_message('You are not admin', 403)
if request.method == 'POST':
form = MarkerPostForm(request.POST)
if form.is_valid():
content = form.cleaned_data['content']
user_from = form.cleaned_data['user_from']
data = { "us_from": user_from,
"marker": content}
return response_json(data, 200)
else:
form = MarkerPostForm(initial={'user_from': 'spont'})
return render(request, 'send_message_from_admin.html', {'form': form})
I try to add my form into an admin panel. I already have django-leaflet and it works normal via LeafletGeoAdmin.
But I need to add my form without a model.
I define a form:
A view:
An extension of admin template:
Result: I see my form, but leaflet map is not shown.
Could you tell me what I did wrong?