Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

TypeError: Direct assignment to the forward side of a many-to-many set is prohibited. Use .set() instead

def form_valid(self, form):
        org = form.cleaned_data.get('organization')
        emails = form.cleaned_data.get("share_email_with")

        users = User.objects.filter(email__in=emails)
        instance = Setupuser.objects.create(organization=org)

        instance.emails_for_help.set(users)

        return redirect("/")
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #Direct #assignment #side #set #Use
ADD COMMENT
Topic
Name
2+2 =