Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/306.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Django突然拒绝加载静态文件_Python_Django - Fatal编程技术网

Python Django突然拒绝加载静态文件

Python Django突然拒绝加载静态文件,python,django,Python,Django,Django服务器已成功加载静态文件,但突然拒绝加载文件。可能是什么问题? 我正在使用Django 2.2.1和Python 3.6 以下是一些可用于识别问题的文件 我所有的静态文件都在静态文件夹中 设置.py STATIC_URL = '/static/' #STATICFILES_DIRS=[os.path.join(BASE_DIR,'static'),] STATIC_ROOT = os.path.join(BASE_DIR, 'static') url.py from django.

Django服务器已成功加载静态文件,但突然拒绝加载文件。可能是什么问题? 我正在使用Django 2.2.1和Python 3.6 以下是一些可用于识别问题的文件 我所有的静态文件都在静态文件夹中

设置.py

STATIC_URL = '/static/'
#STATICFILES_DIRS=[os.path.join(BASE_DIR,'static'),]
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
url.py

from django.urls import path,include
from django.contrib.auth import views as auth_views
from .forms import Vacancy,Personal,Academic,Other

from . import views

app_name='account'

urlpatterns = [
path('', views.home, name='home'),
path('register/', views.registerEduc, name='register'),
path('registerApp/', views.registerApp, name='register_applicant'),
path('signin/', views.user_login, name='signin'),
path('add_student/', views.add_student, name='add_student'),
path('view_student/', views.view_student, name='view_student'),
path('view_applicant/', views.view_applicant, name='view_applicant'),
path('edit_applicant/', views.edit_applicant, name='editApplicant'),
#path('delete_student/?p<student_id>[\w+]+', views.delete_student, name='delete_student'),
path('delete_student/<str:student_id>', views.delete_student, name='delete_student'),
path('search_student/', views.search, name='search_student'),
path('post_vacancy/', views.postVacancy, name='postVacancy'),
path('printDoc/', views.print_pdf, name='print_pdf'),
path('logout/',auth_views.LogoutView.as_view(),name='logout'),
path('dashboard/',views.home_educ,name='dashboard'),
path('dashboardTSC/',views.home_tsc,name='htsc'),
path('apply/',views.FormWizardView.as_view([Vacancy,Personal,Academic,Other]),name='apply'),
path('password_change/',auth_views.PasswordChangeView.as_view(),name='paas.change'),
path('password_change/done/',auth_views.PasswordChangeDoneView.as_view(),name='pass.change.done'),

]
当我在我的项目中添加weasyprint CSS功能时,问题似乎已经出现了,但是现在删除它并不能解决问题,尽管我不知道这是否是原因

下面是函数

def print_pdf(request):
 #applicant = get_list_or_404(Application)
 code=qr.make('TSC Recruitment List')
 code=code.get_image()
 applicant=Application.objects.all()
 html = render_to_string('pdf.report.html',
                        {'applicant': applicant,'code':code})


 response = HttpResponse(content_type='application/pdf')

 response['Content-Disposition'] = 'filename=successful.pdf'
 css=weasyprint.CSS(settings.STATIC_ROOT+'/css/pdf.css')
 weasyprint.HTML(string=html).write_pdf(response,stylesheets=[css])
 return response

请添加详细信息:设置、路径、URL、响应状态。我已经添加了必要的代码。。。社区如何帮助我
def print_pdf(request):
 #applicant = get_list_or_404(Application)
 code=qr.make('TSC Recruitment List')
 code=code.get_image()
 applicant=Application.objects.all()
 html = render_to_string('pdf.report.html',
                        {'applicant': applicant,'code':code})


 response = HttpResponse(content_type='application/pdf')

 response['Content-Disposition'] = 'filename=successful.pdf'
 css=weasyprint.CSS(settings.STATIC_ROOT+'/css/pdf.css')
 weasyprint.HTML(string=html).write_pdf(response,stylesheets=[css])
 return response