Alo*_*eld 4 django migrate base models
我是一个django初学者,我正在尝试制作一个像父母一样的组合框,(酒吧取决于城市取决于国家),我得到这个错误.
更新:更改了外键的模型和默认值,但仍然是相同的错误.有帮助吗?谢谢!
这是models.py:
from django.db import models
from smart_selects.db_fields import ChainedForeignKey
DEFAULT_COUNTRY_ID = 1 # id of Israel
class BarName(models.Model):
name = models.CharField(max_length=20)
def __unicode__(self):
return self.name
class Country(models.Model):
country = models.CharField(max_length=20)
def __unicode__(self):
return self.country
class City(models.Model):
city = models.CharField(max_length=20)
country = models.ForeignKey(Country, default=DEFAULT_COUNTRY_ID)
def __unicode__(self):
return self.city
class Bar(models.Model):
country = models.ForeignKey(Country)
city = ChainedForeignKey(City, chained_field='country' , chained_model_field='country', auto_choose=True)
name = ChainedForeignKey(BarName, chained_field='city', chained_model_field='city', auto_choose=True)
def __unicode__(self):
return '%s %s %s' % (self.name, self.city, self.country)
class Admin:
pass
Run Code Online (Sandbox Code Playgroud)
从运行'python manage.py migrate':
? baromatix python manage.py migrate
Operations to perform:
Apply all migrations: admin, bars, contenttypes, auth, sessions
Running migrations:
.......
value = self.get_prep_value(value)
File "/Library/Python/2.7/site-packages/django/db/models/fields/__init__.py", line 915, in get_prep_value
return int(value)
ValueError: invalid literal for int() with base 10: 'DEFAULT VALUE'
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9389 次 |
| 最近记录: |