Dawid Dave Kosiński
Dawid Dave Kosiński

Reputation: 901

How to show the admin panel in django-geoposition

Today I decided to use an django-geoposition app to show some maps in my project. The problem is that while reading the Docs on github I still don't know what should I write in the admin.py so I could add some maps. Can someone help?

Docs: GitHub of django-geoposition

Upvotes: 0

Views: 992

Answers (1)

David Rivero
David Rivero

Reputation: 36

According to the Documentation, you just have to add a GeopositionField in an attribute:

from django.db import models
from geoposition.fields import GeopositionField

class YourModel(models.Model):
    name = models.CharField(max_length=100)
    map_field = GeopositionField()

So when you go to the model-page on the admin, you can see a map that you can search a location and get the latitude and longitude.

And if you want to allow choosing a location by clicking on the map, just add a few lines on the settings.py:

GEOPOSITION_MARKER_OPTIONS = { 'cursor': 'move' }

https://github.com/philippbosch/django-geoposition

That's all.

Upvotes: 2

Related Questions