python - 将 Django 1.6 升级到 1.7。 "related_name"的通用关系有任何变化吗?

标签 python django upgrade

我正在尝试将项目从 Django 1.6 升级到 1.7。当我尝试运行服务器时,我收到“TypeError: init() got an Unexpected keywords argument 'lated_name'”:

$ ./manage.py runserver --settings=bertondealer.settings.local 0.0.0.0:8000

Traceback (most recent call last):
  File "./manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/home/vagrant/.virtualenvs/dealer17/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 385, in execute_from_command_line
    utility.execute()
  File "/home/vagrant/.virtualenvs/dealer17/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 354, in execute
    django.setup()
  File "/home/vagrant/.virtualenvs/dealer17/local/lib/python2.7/site-packages/django/__init__.py", line 21, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/home/vagrant/.virtualenvs/dealer17/local/lib/python2.7/site-packages/django/apps/registry.py", line 108, in populate
    app_config.import_models(all_models)
  File "/home/vagrant/.virtualenvs/dealer17/local/lib/python2.7/site-packages/django/apps/config.py", line 197, in import_models
    self.models_module = import_module(models_module_name)
  File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/vagrant_data/projects/companyapps/clientes/models.py", line 3, in <module>
    from distribuidores.models import Empresa as Distribuidor
  File "/vagrant_data/projects/companyapps/distribuidores/models.py", line 50, in <module>
    class Empresa(models.Model):
  File "/vagrant_data/projects/companyapps/distribuidores/models.py", line 88, in Empresa
    eventos = generic.GenericRelation(Evento, related_name='distribuidores_set')
  File "/home/vagrant/.virtualenvs/dealer17/local/lib/python2.7/site-packages/django/contrib/contenttypes/fields.py", line 266, in __init__
    from_fields=[self.object_id_field_name], **kwargs)
  File "/home/vagrant/.virtualenvs/dealer17/local/lib/python2.7/site-packages/django/db/models/fields/related.py", line 1309, in __init__
    super(ForeignObject, self).__init__(**kwargs)
TypeError: __init__() got an unexpected keyword argument 'related_name'

这与 Django 1.7 中的任何更改有关吗?

最佳答案

GenericKey 没有 lated_name

但是你可以使用related_query_name而不是 django 1.7 中的 lated_name

关于python - 将 Django 1.6 升级到 1.7。 "related_name"的通用关系有任何变化吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28809924/

相关文章:

python - Blobstore 对于生产来说足够稳定吗?

python - 在 Flask 中,设置一个 cookie,然后重定向用户

css - Django 鹡鸰 :- RichTextField vs Streamfields RichTextBlock styling first letter of paragraph.

ruby-on-rails - Ruby1.9.2从p180升级到p290后,libruby动态库路径没有更新

php - 从 CodeIgniter 1.7.3 转换到 2.0+

python - 使用统计包对数百个协变量进行最大似然估计的方法

python - 无法使用 Pygame 在同一代码中旋转和移动 Sprite

python - 我们可以在 GAE 中运行多处理池吗?

Python 和 Django 将字符串插入数据库

docker - pip 升级 TooManyRedirects 异常