2013-09-23 24 views
1

嗨我試圖使用django-cities連同django-location-field設置與面向用戶的谷歌地圖輸入的地理定位。我添加了以下字段我的模型得到它成立:Django South遷移語法錯誤地理​​位置

class Thing(models.Model): 
    city = models.ForeignKey(City) 
    location = LocationField(based_fields=[city], zoom=7, default=Point(1, 1), srid=3857) 
    objects = models.GeoManager() 

後來我跑了schemamigration:

python2.7 manage.py schemamigration myapp --auto 
? The field 'Thing.city' does not have a default specified, yet is NOT NULL. 
? Since you are adding this field, you MUST specify a default 
? value to use for existing rows. Would you like to: 
? 1. Quit now, and add a default to the field in models.py 
? 2. Specify a one-off value to use for existing columns now 
? Please select a choice: 2 
? Please enter Python code for your one-off default value. 
? The datetime module is available, so you can do e.g. datetime.date.today() 
>>> 0 
+ Added field city on myapp.Thing 
+ Added field location on myapp.Thing 
Created 0002_auto__add_field_thing_city__add_field_thing_location.py. You can now apply this migration with: ./manage.py migrate myapp 

但是,試圖遷移我的應用程序時,我收到此錯誤。我不知道但是如何解決它,:

[myproject]$ python2.7 manage.py migrate 
Traceback (most recent call last): 
    File "manage.py", line 10, in <module> 
    execute_from_command_line(sys.argv) 
    File "/myapp/lib/python2.7/django/core/management/__init__.py", line 443, in execute_from_command_line 
    utility.execute() 
    File "/myapp/lib/python2.7/django/core/management/__init__.py", line 382, in execute 
    self.fetch_command(subcommand).run_from_argv(self.argv) 
    File "/myapp/lib/python2.7/django/core/management/base.py", line 196, in run_from_argv 
    self.execute(*args, **options.__dict__) 
    File "/myapp/lib/python2.7/django/core/management/base.py", line 232, in execute 
    output = self.handle(*args, **options) 
    File "/myapp/lib/python2.7/South-0.7.5-py2.7.egg/south/management/commands/migrate.py", line 107, in handle 
    ignore_ghosts = ignore_ghosts, 
    File "/lib/python2.7/South-0.7.5-py2.7.egg/south/migration/__init__.py", line 166, in migrate_app 
    Migrations.calculate_dependencies() 
    File "/lib/python2.7/South-0.7.5-py2.7.egg/south/migration/base.py", line 227, in calculate_dependencies 
    migration.calculate_dependencies() 
    File "/lib/python2.7/South-0.7.5-py2.7.egg/south/migration/base.py", line 358, in calculate_dependencies 
    for migration in self._get_dependency_objects("depends_on"): 
    File "/lib/python2.7/South-0.7.5-py2.7.egg/south/migration/base.py", line 338, in _get_dependency_objects 
    for app, name in getattr(self.migration_class(), attrname, []): 
    File "/lib/python2.7/South-0.7.5-py2.7.egg/south/migration/base.py", line 310, in migration_class 
    return self.migration().Migration 
    File "/lib/python2.7/South-0.7.5-py2.7.egg/south/utils/__init__.py", line 62, in method 
    value = function(self) 
    File "/lib/python2.7/South-0.7.5-py2.7.egg/south/migration/base.py", line 301, in migration 
    raise exceptions.BrokenMigration(self, sys.exc_info()) 
south.exceptions.BrokenMigration: While loading migration 'myapp:0002_auto__add_field_thing_city__add_field_thing_location': 
Traceback (most recent call last): 
    File "/lib/python2.7/South-0.7.5-py2.7.egg/south/migration/base.py", line 297, in migration 
    migration = __import__(full_name, {}, {}, ['Migration']) 
    File "/myapp/myproject/myapp/migrations/0002_auto__add_field_thing_city__add_field_thing_location.py", line 18 
    self.gf('location_field.models.LocationField')(default=<Point object at 0x277eeb0>, srid=3857), 
                ^
SyntaxError: invalid syntax 

我怎樣才能解決這個問題的SyntaxError?感謝您的想法!

回答

0

刪除先前的遷移解決了問題。關於我命名模型字段的方式,但我不確定發生了什麼......