Can I give parameters to AppConfig.ready() of django?
Question:
I want to get request.user.id as I have to pass it to scheduler in AppConfig.ready() but it gave an error. How can I do it ?
My code is as follows:
class ApiConfig(AppConfig):
name = 'myapp'
def ready(self, request):
print('Here starting scheduler')
from . import msgScheduler
user_id = request.user.id
msgScheduler.start(self,request, user_id)
Answers:
ready
function is not called by HttpRequest, so you cannot get any request or authenticated user…
You have to start your scheduler without a request/user or run the start
function from a view
I want to get request.user.id as I have to pass it to scheduler in AppConfig.ready() but it gave an error. How can I do it ?
My code is as follows:
class ApiConfig(AppConfig):
name = 'myapp'
def ready(self, request):
print('Here starting scheduler')
from . import msgScheduler
user_id = request.user.id
msgScheduler.start(self,request, user_id)
ready
function is not called by HttpRequest, so you cannot get any request or authenticated user…
You have to start your scheduler without a request/user or run the start
function from a view