satyajit
satyajit

Reputation: 694

TypeError: save() missing 1 required positional argument: 'self' : DjangoRestframework

I'm getting an error, save() missing 1 required positional argument: 'self' .
I have no idea where I made mistake, it would be great if anybody could figure out the mistake, they would be much appreciated.

serializers.py

           UserOtherInfo_obj = User(
                device_token    =   device_token,
                device_type     =   device_type,
                phone_number    =   phone_number,
                country_code    =   country_code,
                login_type      =   login_type
            )    
            
            UserOtherInfo_temp  =  User.save()
            
            temp_user1 = User.objects.filter(user=temp_user)
            print('temp_user1',temp_user1)
            UserOtherObj = temp_user1.first()    

Upvotes: 0

Views: 773

Answers (1)

Biplove Lamichhane
Biplove Lamichhane

Reputation: 4095

I think it should be:

UserOtherInfo_temp  =  UserOtherInfo_obj.save()

Before, you directly were calling save on User model, but you can save only the instance of User model, which you instantiated just a line above i.e:

UserOtherInfo_obj = User(
                device_token    =   device_token,
                device_type     =   device_type,
                phone_number    =   phone_number,
                country_code    =   country_code,
                login_type      =   login_type
            ) 

Here, UserOtherInfo_obj is instance of User model.

Upvotes: 2

Related Questions