我有两个模型:
class Someinfo(models.Model):
name = models.CharField(max_length=200)
#something else
class OtherInfo(models.Model):
name2 = models.CharField(max_lenth=200)
related_someinfo = models.ManyToManyField(Someinfo)
#something else
Run Code Online (Sandbox Code Playgroud)
现在我已经创建了 CBV 视图来创建和查看它们。CreateView 工作正常并保存可以在管理员中查看的信息,但我无法让模板在任何其他视图上显示数据,无论是 FormView、DetailView 还是任何其他视图,因为我收到此错误:
__call__() missing 1 required keyword-only argument: 'manager'
Request Method: GET
Request URL: http://something
Django Version: 2.0.3
Exception Type: TypeError
Exception Value:
__call__() missing 1 required keyword-only argument: 'manager'
Exception Location: /usr/local/lib/python3.5/dist-packages/django/forms/forms.py in get_initial_for_field, line 494
Python Executable: /usr/bin/python3
Python Version: 3.5.3
Run Code Online (Sandbox Code Playgroud)
检查 forms.py 中的行,它表明不起作用的函数是:
def get_initial_for_field(self, field, field_name):
"""
Return initial data for field on form. …Run Code Online (Sandbox Code Playgroud) django ×1