[Answer]-Sleekxmpp with Django not working?

1👍

Your method aaaa always return None. Try to use self.

Also it is not a good idea to multiple inheritance here. Try aggregation

class SendMessageView(APIView):

    def aaaa(self,jid, password, recipient, message):
        ...
        self.xmpp = sleekxmpp.ClientXMPP(jid, password)
        ...

    def post(self,request,format=None):
        ...    
        self.aaaa(jid,password,receiver,message)

        self.xmpp.register_plugin('xep_0030')
        self.xmpp.register_plugin('xep_0199')
        ...

Or even better:

class SendMessageView(APIView):

    def get_xmpp(self,jid, password, recipient, message):
        ...
        return sleekxmpp.ClientXMPP(jid, password)
        ...

    def post(self,request,format=None):
        ...    
        xmpp = self.get_xmpp(jid,password,receiver,message)

        xmpp.register_plugin('xep_0030')
        xmpp.register_plugin('xep_0199')
        ...

Leave a comment