[Django]-Setting a Generic Foreign Key in Django while still sane

5👍

If you call save() with commit=False (in form object), then it will return an object that hasn’t yet been saved to the database. But you continue to work with the object form rather than the object of the model.

Try this:

stream_instance = stream_form.save(commit=False)
stream_instance.content_object = attempt
stream_instance.save()

Leave a comment