I am trying to create a somewhat simple model, but I am having troubles. The model is simply a week number (which is unique and functions as the primary key) and a ManyToMany relationship to my custom User model. Meaning a week e.g, 32 can have a series of users related to it. What I then want to do is that, say week 32 already has a series of users related to it, then when we give week 32 a new series users then it should simply overwrite the old with the new users. I have created the following model,
with the following serializer,
and the view,
The get request works as expected. However when I make a post request with a new week number (one not present in the database) it seems to actually create the database row as expected but it still produces an error in the console,
` TypeError: Schema() got an unexpected keyword argument 'user_ids' ` and
` TypeError: Got a `TypeError` when calling `Schema.objects.create()`. This may be because you have a writable field on the serializer class that is not a valid argument to `Schema.objects.create()`. You may need to make the field read-only, or override the SchemaSerializer.create() method to handle this correctly. `.
When I make a post request with a week number already in the database the, `.is_valid()` check simply fails and I get a 400.
Any ideas why this might be, or any ways that I can simply rewrite the model/serializer/view, to make it work. I feel I have tried so many things by now. Any help is greatly appreciated!