Alexandr Domoryonok Alexandr Domoryonok - 8 months ago 59
Python Question

'ManyToManyDescriptor' object has no attribute 'add', why?

So I refer to another model :

subscriptions = models.ManyToManyField(Season)

So I use :

def buy_season(request):
_id = 1
season = Season.objects.get(id = _id)

a = ExtUser.subscriptions.add(season)

return Response({'status': 'success'}, status=status.HTTP_200_OK)

I get an error object 'ManyToManyDescriptor' does not attribute the "Add"
Do many to many directly , and not through the " throw " , why there is this error ?


You should use an instance of the ExtUser model as you cannot add a model object directly to a class object.