-
Notifications
You must be signed in to change notification settings - Fork 209
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ajax.py: get object by PK on form rendering #816
Conversation
If the solution is good enough, the linter recommendations will be added later |
Thanks for the PR, Can you please explain in the issue/PR how you are solving this? I thought this was a new feature TBH, not sure what it is fixing. |
When render a form, relationship field contains not an object, but string, which leads to the exception discussed in the aforementioned PR ( I suggest to fetch an object from database in such cases (when a string is passed to loader.format() method). What I'm doubt of is all cases I cover with that solution or missing something |
Can you open a new issue with a sample code? |
It would be literally the same as in PR #727:
So, we could either teach the def process_formdata(self, valuelist: list) -> None:
if valuelist:
if self.allow_blank and valuelist[0] == "__None":
self.data = None
else:
self._data = None
value = valuelist[0]
# here we go
if isinstance(value , str):
self._formdata = self.loader.get_object(value)
else:
self._formdata = value |
Does this workaround fix the issue described in PR #727?