I have two models:
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
Now I have created CBV views to create and view them. The CreateView works fine and saves info that can be reviewed in admin, but I cannot get the template to display the data on any other view be it FormView, DetailView or any other, because I get this error:
__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
Checking the line in forms.py it shows that the function that is not working is:
def get_initial_for_field(self, field, field_name):
"""
Return initial data for field on form. Use initial data from the form
or the field, in that order. Evaluate callable values.
"""
value = self.initial.get(field_name, field.initial)
if callable(value):
value = value() # line 494
return value
Any suggestions? I can query the linked objects via shell and they are saved in the database, so I have no idea how to proceed.
Here is my case, I am using django shell:
python manage.py shell
There are two models: Topic
and Entry
. I tried to get all entries
from Topic
which id
is 1
.
>>> Topic.objects.get(id=1)
<Topic: Chess>
>>> t = Topic.objects.get(id=1)
>>> t.entry_set().all()
Traceback (most recent call last):
File "<console>", line 1, in <module>
TypeError: __call__() missing 1 required keyword-only argument: 'manager'
>>> t.entry_set.all()
<QuerySet [<Entry: Ah okey, so when testing for a console.log (or oth...>]>
>>>
The correct command is: t.entry_set.all()
, not t.entry_set().all()
use entry_set instead of entry_set()(wihout brackets )
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With