我有一个正在运行的项目,我想向其中一个模型添加一个新字段。
我添加了新字段并运行了makemigrations
命令,然后得到了ValueError: too many values to unpack
class Line(models.Model):
name = models.CharField(max_length=250, null=False, blank=False, unique=True)
label_name = models.CharField(max_length=250, null=True, blank=True, unique=True)
我想添加此字段:
link = models.CharField(max_length=200,null=True,blank=True, unique=True)
然后我运行了makemigrations
命令,并得到了此异常异常:
Traceback (most recent call last):
File "C:\Program Files\JetBrains\PyCharm 2017.3.3\helpers\pycharm\django_manage.py", line 52, in <module>
run_command()
File "C:\Program Files\JetBrains\PyCharm 2017.3.3\helpers\pycharm\django_manage.py", line 46, in run_command
run_module(manage_file, None, '__main__', True)
File "C:\Python27\lib\runpy.py", line 176, in run_module
fname, loader, pkg_name)
File "C:\Python27\lib\runpy.py", line 82, in _run_module_code
mod_name, mod_fname, mod_loader, pkg_name)
File "C:\Python27\lib\runpy.py", line 72, in _run_code
exec code in run_globals
File "F:\cellular_resolution_map_of_larval_zebrafish\manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line 350, in execute_from_command_line
utility.execute()
File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line 342, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Python27\lib\site-packages\django\core\management\base.py", line 348, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\Python27\lib\site-packages\django\core\management\base.py", line 399, in execute
output = self.handle(*args, **options)
File "C:\Python27\lib\site-packages\django\core\management\commands\makemigrations.py", line 105, in handle
loader.project_state(),
File "C:\Python27\lib\site-packages\django\db\migrations\loader.py", line 338, in project_state
return self.graph.make_state(nodes=nodes, at_end=at_end, real_apps=list(self.unmigrated_apps))
File "C:\Python27\lib\site-packages\django\db\migrations\graph.py", line 280, in make_state
project_state = self.nodes[node].mutate_state(project_state, preserve=False)
File "C:\Python27\lib\site-packages\django\db\migrations\migration.py", line 88, in mutate_state
operation.state_forwards(self.app_label, new_state)
File "C:\Python27\lib\site-packages\django\db\migrations\operations\fields.py", line 51, in state_forwards
state.reload_model(app_label, self.model_name_lower)
File "C:\Python27\lib\site-packages\django\db\migrations\state.py", line 148, in reload_model
self.apps.render_multiple(states_to_be_rendered)
File "C:\Python27\lib\site-packages\django\db\migrations\state.py", line 296, in render_multiple
model.render(self)
File "C:\Python27\lib\site-packages\django\db\migrations\state.py", line 585, in render
body,
File "C:\Python27\lib\site-packages\django\db\models\base.py", line 158, in __new__
new_class.add_to_class(obj_name, obj)
File "C:\Python27\lib\site-packages\django\db\models\base.py", line 299, in add_to_class
value.contribute_to_class(cls, name)
File "C:\Python27\lib\site-packages\django\db\models\fields\related.py", line 702, in contribute_to_class
super(ForeignObject, self).contribute_to_class(cls, name, virtual_only=virtual_only)
File "C:\Python27\lib\site-packages\django\db\models\fields\related.py", line 308, in contribute_to_class
lazy_related_operation(resolve_related_class, cls, self.remote_field.model, field=self)
File "C:\Python27\lib\site-packages\django\db\models\fields\related.py", line 85, in lazy_related_operation
return apps.lazy_model_operation(partial(function, **kwargs), *model_keys)
File "C:\Python27\lib\site-packages\django\db\models\fields\related.py", line 83, in <genexpr>
model_keys = (make_model_tuple(m) for m in models)
File "C:\Python27\lib\site-packages\django\db\models\utils.py", line 13, in make_model_tuple
app_label, model_name = model.split(".")
ValueError: too many values to unpack
我该如何解决?
非常感谢您。