Coder Social home page Coder Social logo

django-osm-field's Issues

Support for Django 1.7

Hi Marcus,

I am working on a project with Django 1.7.1 (Python 2.7.8, PostgreSQL 9.3.5) and the model contains the OSMField:

...
location = OSMField(verbose_name=_('Location'))
....

When running

$ ./manage.py makemigrations appointments
$ ./manage.py migrate appointments

it fails with

Operations to perform:
  Apply all migrations: appointments
Running migrations:
  Applying appointments.0001_initial...Traceback (most recent call last):
  File "./manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/home/sinn/foo/lib/python2.7/site-packages/django/core/management/__init__.py", line 385, in execute_from_command_line
    utility.execute()
  File "/home/sinn/foo/lib/python2.7/site-packages/django/core/management/__init__.py", line 377, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/sinn/foo/lib/python2.7/site-packages/django/core/management/base.py", line 288, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/home/sinn/foo/lib/python2.7/site-packages/django/core/management/base.py", line 338, in execute
    output = self.handle(*args, **options)
  File "/home/sinn/foo/lib/python2.7/site-packages/django/core/management/commands/migrate.py", line 160, in handle
    executor.migrate(targets, plan, fake=options.get("fake", False))
  File "/home/sinn/foo/lib/python2.7/site-packages/django/db/migrations/executor.py", line 63, in migrate
    self.apply_migration(migration, fake=fake)
  File "/home/sinn/foo/lib/python2.7/site-packages/django/db/migrations/executor.py", line 97, in apply_migration
    migration.apply(project_state, schema_editor)
  File "/home/sinn/foo/lib/python2.7/site-packages/django/db/migrations/migration.py", line 107, in apply
    operation.database_forwards(self.app_label, schema_editor, project_state, new_state)
  File "/home/sinn/foo/lib/python2.7/site-packages/django/db/migrations/operations/models.py", line 36, in database_forwards
    schema_editor.create_model(model)
  File "/home/sinn/foo/lib/python2.7/site-packages/django/db/backends/schema.py", line 263, in create_model
    self.execute(sql, params)
  File "/home/sinn/foo/lib/python2.7/site-packages/django/db/backends/schema.py", line 99, in execute
    cursor.execute(sql, params)
  File "/home/sinn/foo/lib/python2.7/site-packages/django/db/backends/utils.py", line 81, in execute
    return super(CursorDebugWrapper, self).execute(sql, params)
  File "/home/sinn/foo/lib/python2.7/site-packages/django/db/backends/utils.py", line 65, in execute
    return self.cursor.execute(sql, params)
  File "/home/sinn/start-green/lib/python2.7/site-packages/django/db/utils.py", line 94, in __exit__
    six.reraise(dj_exc_type, dj_exc_value, traceback)
  File "/home/sinn/foo/lib/python2.7/site-packages/django/db/backends/utils.py", line 65, in execute
    return self.cursor.execute(sql, params)
django.db.utils.ProgrammingError: column "location_lat" specified more than once

Do you have an idea what might be wrong?

Can't seem to attach text files, hence a link to the migration file:
http://paste.awesom.eu/Yzpm

TypeError: $(...).osmfield is not a function

Hi, when I try to use this in admin panel, with plain django 1.8 - it works fine.
But when we add some admin packages, like django-easy-select2 which uses jquery as well, then this package fails to start, and firebug shows:

TypeError: $(...).osmfield is not a function

I fixed issue by replacing line in osm_field.(min)?.js from

(function($) {

into

jQuery(document).ready(function(jQuery) {

and removing

(jQuery)

from the last line.

Not sure it's a good approach, but it works at least ;-)

Decimal degrees coordinates ingored, showing only the nearest object

To reproduce: paste any decimal degrees coordinates under which there are no objects in OSM to the location field. 49.415248, 26.957707 for example.

Expected result: pointer put directly on these coordinates.

Actual result: pointer put on the nearest object (road, town) that can be several kilometres away.

I think it should be addressed in the django-osm-field because Nominatim's function is just different.

And _lat, _lon fields changes are ignored on the map in my case, is that a bug?

Doesn't work in formsets

This is the HTML generated by OSMField when it's in a formset:

<input class="form-control osmfield osmfield-input" data-lat-field="latitude" data-lon-field="longitude" id="id_times-1-location" name="times-1-location" placeholder="Location" prefix="times-1" title="" type="text">
<!--          These are used to target other inputs ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ -->
<script type="application/javascript">$(function(){$("#id_times-1-location").osmfield();});</script>
<input id="id_times-1-latitude" name="times-1-latitude" type="hidden">
<!--   ^^^^^^^^^^^^^^^^^^^^^^^^ should target this -->
<input id="id_times-1-longitude" name="times-1-longitude" type="hidden">
<!--   ^^^^^^^^^^^^^^^^^^^^^^^^ should target this -->

As you can see, data-lat-field refers to #latitude, but there's no #latitude id on the page, there's an id_times-1-latitude id, which is what it should be targeting.

There needs to be a way to add the form's prefix attribute to the data-lat-field and data-lon-field attributes of the OSMField.

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.