python - Error When Using Mechanize in Custom Module Imported to Django views.py file -
i cannot life of me figure out what's going on here. making site django takes username , password of logging in, runs through python script uses mechanize scrape site, , math , displays data. problem appears mechanize when trying run file live django. obviously, scraping script works fine when run alone. here traceback , all.
environment: request method: post request url: http://127.0.0.1:8000/ django version: 1.11.4 python version: 2.7.12 installed applications: ['webapp', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles'] installed middleware: ['django.middleware.security.securitymiddleware', 'django.contrib.sessions.middleware.sessionmiddleware', 'django.middleware.common.commonmiddleware', 'django.middleware.csrf.csrfviewmiddleware', 'django.contrib.auth.middleware.authenticationmiddleware', 'django.contrib.messages.middleware.messagemiddleware', 'django.middleware.clickjacking.xframeoptionsmiddleware'] traceback: file "/usr/local/lib/python2.7/site-packages/django/core/handlers/exception.py" in inner 41. response = get_response(request) file "/usr/local/lib/python2.7/site-packages/django/core/handlers/base.py" in _get_response 187. response = self.process_exception_by_middleware(e, request) file "/usr/local/lib/python2.7/site-packages/django/core/handlers/base.py" in _get_response 185. response = wrapped_callback(request, *callback_args, **callback_kwargs) file "/users/jackditto/desktop/django site/mysite/webapp/views.py" in login 22. information = mysa_scrape.get_grades(login, password) file "/usr/local/lib/python2.7/site-packages/django/modules/mysa_scrape.py" in get_grades 90. login(username, password) file "/usr/local/lib/python2.7/site-packages/django/modules/mysa_scrape.py" in login 31. response = mechanize.urlopen(request, data=encoded_params) file "/usr/local/lib/python2.7/site-packages/mechanize/_opener.py" in urlopen 433. return get_thread_local_opener().open(url, data, timeout) file "/usr/local/lib/python2.7/site-packages/mechanize/_opener.py" in get_thread_local_opener 426. ans = thread_local.opener exception type: attributeerror @ / exception value: 'thread._local' object has no attribute 'opener'
Comments
Post a Comment