I am developing an application in python 2.7 and using Django, when I run it on my local machine (windows 7) it runs well without any error, but when I try to run it in a virtual machine with ubuntu server where it also used to work well, it crashes with the following error
This is my project working tree:
- MYSITE
* BMM
·admin.py
·apps.py
·models.py
·pdf_utils.py
·urls.py
·views.py
*Mysite
·settings.py
·urls.py
·wsgi.py
This is the app\\urls.py file:
from django.conf.urls import url
from wkhtmltopdf.views import PDFTemplateView
from . import views
urlpatterns = [
url(r'^$', views.index, name='index'),
# url(r'^$', views.pdf, name='pdf'),
# url(r'^$', views.ganttChart, name='ganttChart'),
url(r'^pdf/$', PDFTemplateView.as_view(template_name='billReport.html',filename='my_pdf.pdf'), name='pdf'),
url(r'^report/$', views.report, name='report'),
]
And this is the mysite/urls.py file:
from django.conf.urls import include, url
from django.contrib import admin
#from wkhtmltopdf.views import PDFTemplateView
urlpatterns = [
url(r'',include('bmm.urls')),
url(r'^ganttchart/', include('bmm.urls')),
url(r'^admin/', admin.site.urls),
#url(r'^pdf/$', PDFTemplateView.as_view(template_name='billReport.html', filename='my_pdf.pdf'), name='pdf'),
]
Any help about how to solve this would be really appreciated
error you are getting is self-explanatory.
It seems you have installed wrong package. you have installed wkhtmltopdf package which has no module named "view". That's why you are getting error : "No module named views"
The correct package is django-wkhtmltopdf , which has module named "view".
Uninstall wkhtmltopdf and install django-wkhtmltopdf . You can find installation and setup instruction for django-wkhtmltopdf here .
1.pip uninstall wkhtmltopdf
2.pip install django-wkhtmltopdf
Don't forget to put wkhtmltopdf
in `INSTALLED_APPS:
INSTALLED_APPS = (
# ...
'wkhtmltopdf',
# ...
)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.