madisona / django-google-maps

Using the Google Maps API with django model admin
BSD 2-Clause "Simplified" License
281 stars 99 forks source link

DjangoREST #28

Closed elcolie closed 6 years ago

elcolie commented 6 years ago

Does it support Django REST? I don't see anything on this

madisona commented 6 years ago

@elcolie The project itself is simply a couple model fields and widgets to help work with Google Maps. The model fields themselves could be used in a project that used Django REST if you'd like, just like any other model field.

elcolie commented 6 years ago

Yes. I understand I can use it like other model field. But I found it is not implement anything else. It just a plain CharField.

class SampleModelSerializer(serializers.ModelSerializer):
    class Meta:
        model = SampleModel
        fields = [
            'address',
            'geolocation',
        ]

I expect dedicated field with validator built-in not CharField without anything else

In [1]: from sample.api.serializers import *
In [2]: SampleModelSerializer()
Out[2]:
SampleModelSerializer():
    address = CharField(max_length=100)
    geolocation = CharField(allow_blank=True, max_length=100, required=False)

But I don't know how to make a GeolocationSerializer class. Therefore I make the PR to you since you know how to make a package.