I'm following the guide : https://flask-restplus.readthedocs.io/en/stable/scaling.html
I define namespace in each namespace class and the 'api' is defined in init.py.
In init.py
from flask_restplus import Api
from .AA import nsAA
api = Api()
api.add_namespace(nsAA)
In AA.py (which is namespace)
from flask_restplus import Resource, Namespace, marshal_with, fields
nsAA = Namespace('')
@nsAA.route('/login')
class AA(Resource):
login_fields = api.model('Resource', {
'username': fields.String,
'password': fields.String,
})
@api.expect(login_fields)
def post(self):
I got error:
AttributeError: 'AA' object has no attribute 'api'
I understand that this error as there is no 'api' instance in namespace.
But how can I pass it to namespace?