-
Notifications
You must be signed in to change notification settings - Fork 204
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Value too long for type character varying(42) #53
Comments
I'm also seeing this behavior in Django 1.9 (#58) |
This seems to be the root cause on the #58 branch:
Really not sure why this is returning as a list of |
Fixed on #58 |
Have this error in |
Me too, with Django 1.10.2, django-geoposition 0.3.0 and PostgreSQL Database |
I had the same problem with a CreateView of my project and find the solution. The problem is that the Decimal lat and long coordinates are not expected when creating a model instance. The location field must be the Geoposition instance. So, you should import this class as the following : from geoposition import Geoposition and create instance and pass this instance in form_valid as like as the following: if place.is_valid():
cd = place.cleaned_data
location = cd.get('location')
geo_location = Geoposition(location[0], location[1])
place_obj, created = PlaceOfEvent.objects.get_or_create(location=geo_location) |
I have a model with a
GeoPosition
field in it. When I create a new instance through the admin, I get the nice map widget that lets me pinpoint the location. However, when I try to save certain locations, I get an exception thrown:value too long for type character varying(42)
I checked the table of my model in the DB and the geoposition field is the only column defined as varchar(42).
The way I chose that location seems to be part of the issue. If I drag the icon to where I want it, it seems to work. This is the way I've been doing it so far, but today while filling out the admin form, I tabbed through all the fields until I got to the latitude field, at which point the map zoomed in to a spot in the ocean. Since I'm still testing my app, I moved the icon to any random spot of that part of the ocean, saw the lat/long widgets be filled with random coordinates, and kept on filling out the form.
When I did it this way, the latitude and longitude fields had many decimal places in them, apparently more than the DB column can hold, which django was happy to point out to me in the form of an exception.
I have no idea what the standard is for latitude and longitude number length, or if there even is a standard, but perhaps the max length of that column can be increased to something that plays nice with the admin widget?
The text was updated successfully, but these errors were encountered: