Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from django.contrib.gis.db import models as geomodels
- from django.db import models
- class AddPoint(models.Model):
- name = models.CharField(max_length=100)
- point = geomodels.PointField()
- def __str__(self):
- return self.name
- from django import forms
- from django.contrib.gis import forms
- class AddPointForm(forms.ModelForm):
- name = forms.CharField(
- max_length=100,
- widget=forms.TextInput(
- attrs={
- "type": "text",
- "class": "form-control form-control-lg",
- }
- ),
- )
- point = forms.PointField(
- widget=forms.OSMWidget(
- attrs={
- 'map_width': 800,
- 'map_height': 500,
- }
- ),
- )
- class Meta:
- model = AddPoint
- fields = []
- def addPointOnMap(request):
- if request.method == "POST":
- geoform = AddPointForm(request.POST or None)
- if geoform.is_valid():
- new_point = geoform.save()
- new_point.save()
- return redirect('add_points_map')
- else:
- geoform = AddPointForm()
- context = {
- 'geoform': geoform,
- }
- template = 'maps/editing/add_point.html'
- return render(request, template, context)
- <form method="POST" enctype="multipart/form-data" novalidate>{% csrf_token %}
- {{ geoform.as_p }}
- <hr>
- <div class="row justify-content-md-center">
- <div class="col-md-auto">
- <input type="submit" class="btn btn-info shadow" value="SHARE">
- </div>
- </div>
- </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement