[Fixed]-Django and DB modeling: I think I've got Many to Many wrong


I don’t really understand why you create a new Option here. You get the existing one; you can just add that to the relationship:

consumer = get_object_or_404(Consumer, pk=pk)
option = get_object_or_404(Option, pk=option_pk)

You don’t even need to call save, as modifying an m2m does not change the instance itself.

Leave a comment