Coder Social home page Coder Social logo

Comments (12)

madisona avatar madisona commented on July 19, 2024

it should - have you run your database migrations?

from django-google-maps.

fredericpierron avatar fredericpierron commented on July 19, 2024

yes, I have even flush and erase migrations to start fresh.

from django-google-maps.

madisona avatar madisona commented on July 19, 2024

can you show what your model looks like? The tests pass under the versions you're using. https://travis-ci.org/github/madisona/django-google-maps

from django-google-maps.

fredericpierron avatar fredericpierron commented on July 19, 2024

Models.py uses:

from django.db import models
from django_google_maps import fields as map_fields

class Location(models.Model):
    address = map_fields.AddressField(max_length=200)
    geolocation = map_fields.GeoLocationField(max_length=100)

and admin uses:

from django.contrib import admin
from django_google_maps import widgets as map_widgets
from django_google_maps import fields as map_field

class LocationAdmin(admin.ModelAdmin):
    formfield_overrides = {
        map_fields.AddressField: {'widget': map_widgets.GoogleMapsAddressWidget},
    }

from django-google-maps.

fredericpierron avatar fredericpierron commented on July 19, 2024

Full Models for your test:

from django.db import models
from django_google_maps import fields as map_fields


class Subscriber(models.Model):
    login  = models.CharField(max_length=200, unique=True)
    email  = models.CharField(max_length=200, unique=True)
    country  = models.CharField(max_length=100)

    def __str__(self):
        return self.email

class Location(models.Model):
    address = map_fields.AddressField(max_length=200)
    geolocation = map_fields.GeoLocationField(max_length=100)


class Video(models.Model):
    video_title = models.CharField(max_length=200)
    video_url = models.CharField(max_length=255, unique=True)
    video_file = models.CharField(max_length=50)
    video_date = models.DateTimeField('date published')
    video_user = models.ForeignKey(Subscriber, on_delete=models.CASCADE)
    loc = models.ForeignKey(Location, on_delete=models.CASCADE)

    def __str__(self):
        return self.video_title + " / " + self.video_file

and full admin:

from django.contrib import admin
from django_google_maps import widgets as map_widgets
from django_google_maps import fields as map_fields

from .models import Video, Subscriber, Location


class VideoAdmin(admin.ModelAdmin):
    fields = [ 'video_title', 'video_user', 'video_date', 'video_url', 'video_file' ]


class LocationAdmin(admin.ModelAdmin):
    formfield_overrides = {
        map_fields.AddressField: {'widget': map_widgets.GoogleMapsAddressWidget},
    }


admin.site.register(Location, LocationAdmin)
admin.site.register(Video, VideoAdmin)
admin.site.register(Subscriber)

from django-google-maps.

madisona avatar madisona commented on July 19, 2024

and can you from the DBShell desc the location table to make sure it exists in the database?

from django-google-maps.

fredericpierron avatar fredericpierron commented on July 19, 2024
 ;
+---------+--------------+------+-----+---------+----------------+
| Field   | Type         | Null | Key | Default | Extra          |
+---------+--------------+------+-----+---------+----------------+
| id      | int(11)      | NO   | PRI | NULL    | auto_increment |
| name    | varchar(100) | NO   |     | NULL    |                |
| gps     | point        | NO   | MUL | NULL    |                |
| address | varchar(100) | NO   |     | NULL    |                |
| city    | varchar(50)  | NO   |     | NULL    |                |
+---------+--------------+------+-----+---------+----------------+
5 rows in set (0.00 sec)

from django-google-maps.

madisona avatar madisona commented on July 19, 2024

Ok - there isn't a field called geolocation which is why you're getting the error. Exception Value: (1054, "Unknown column 'wbmap_location.geolocation' in 'field list'")

from django-google-maps.

fredericpierron avatar fredericpierron commented on July 19, 2024

ok, so you mean my field gps should be renamed geolocation to work? I give a try.

from django-google-maps.

fredericpierron avatar fredericpierron commented on July 19, 2024

Ok, after erasing by hand all migrations, databas, table, caches, ... I've recreated the models, with geolocation in name of the field and the admin works almost. The map does not appears (maybe a bad Gmap key? to be checked). Thanks.

from django-google-maps.

fredericpierron avatar fredericpierron commented on July 19, 2024

OK, now it works.
Static files were missing. As I've installed through pip, i thought everything would come in the right place. After creating folder for static, it's okay now.

Thanks for your help.

from django-google-maps.

madisona avatar madisona commented on July 19, 2024

you bet - good luck with your project

from django-google-maps.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.