我正在尝试实现django-funky-sheets(https://pypi.org/project/django-funky-sheets/)软件包,但是一旦添加{%include hot_template%}标记,我就会不断收到“拒绝权限”错误。
在安装和设置过程中,我做了以下事情:
pip install django-funky-sheets
settings.py
INSTALLED_APPS = [
...
'funky_sheets',
...
]
urls.py
path('adres/funky/create/', CreateFunkyView.as_view(), name='funky-create'),
path('adres/funky/update/', UpdateFunkyView.as_view(), name='funky-update'),
views.py
class CreateFunkyView(HotView):
model = Adres
template_name = 'bierviltje/vilt_detail.html'
prefix = 'table'
succes_url = reverse_lazy('funky-update')
fields = (
'id',
'adres_title',
'm2',
)
hot_settings = {
'contextMenu': 'true',
'autoWrapRow': 'true',
'rowHeaders': 'true',
'contextMenu': 'true',
'search': 'true',
'licenseKey': 'non-commercial-and-evaluation',
}
def get_context_data(self, **kwargs):
context = super(CreateFunkyView, self).get_context_data(**kwargs)
context['vilt'] = self.model.vilt
class UpdateFunkyView(CreateFunkyView):
template_name = 'bierviltje/vilt_detail.html'
action = 'update'
button_text = 'Update'
vilt_detail.html
...
<div class="row">
{% include hot_template %}
</div>
...
我不断收到的错误消息是: [Errno 13]权限被拒绝:'C:\ Users \ [用户名] \ [项目] \ bierviltje \ templates'
这是回溯:
Traceback (most recent call last):
File "C:\Users\chris\Envs\koka\lib\site-packages\django\core\handlers\exception.py", line 34, in inner
response = get_response(request)
File "C:\Users\chris\Envs\koka\lib\site-packages\django\core\handlers\base.py", line 156, in _get_response
response = self.process_exception_by_middleware(e, request)
File "C:\Users\chris\Envs\koka\lib\site-packages\django\core\handlers\base.py", line 154, in _get_response
response = response.render()
File "C:\Users\chris\Envs\koka\lib\site-packages\django\template\response.py", line 106, in render
self.content = self.rendered_content
File "C:\Users\chris\Envs\koka\lib\site-packages\django\template\response.py", line 83, in rendered_content
content = template.render(context, self._request)
File "C:\Users\chris\Envs\koka\lib\site-packages\django\template\backends\django.py", line 61, in render
return self.template.render(context)
File "C:\Users\chris\Envs\koka\lib\site-packages\django\template\base.py", line 171, in render
return self._render(context)
File "C:\Users\chris\Envs\koka\lib\site-packages\django\template\base.py", line 163, in _render
return self.nodelist.render(context)
File "C:\Users\chris\Envs\koka\lib\site-packages\django\template\base.py", line 937, in render
bit = node.render_annotated(context)
File "C:\Users\chris\Envs\koka\lib\site-packages\django\template\base.py", line 904, in render_annotated
return self.render(context)
File "C:\Users\chris\Envs\koka\lib\site-packages\django\template\loader_tags.py", line 150, in render
return compiled_parent._render(context)
File "C:\Users\chris\Envs\koka\lib\site-packages\django\template\base.py", line 163, in _render
return self.nodelist.render(context)
File "C:\Users\chris\Envs\koka\lib\site-packages\django\template\base.py", line 937, in render
bit = node.render_annotated(context)
File "C:\Users\chris\Envs\koka\lib\site-packages\django\template\base.py", line 904, in render_annotated
return self.render(context)
File "C:\Users\chris\Envs\koka\lib\site-packages\django\template\loader_tags.py", line 62, in render
result = block.nodelist.render(context)
File "C:\Users\chris\Envs\koka\lib\site-packages\django\template\base.py", line 937, in render
bit = node.render_annotated(context)
File "C:\Users\chris\Envs\koka\lib\site-packages\django\template\base.py", line 904, in render_annotated
return self.render(context)
File "C:\Users\chris\Envs\koka\lib\site-packages\django\template\loader_tags.py", line 176, in render
template = context.template.engine.get_template(template_name)
File "C:\Users\chris\Envs\koka\lib\site-packages\django\template\engine.py", line 144, in get_template
template, origin = self.find_template(template_name)
File "C:\Users\chris\Envs\koka\lib\site-packages\django\template\engine.py", line 126, in find_template
template = loader.get_template(name, skip=skip)
File "C:\Users\chris\Envs\koka\lib\site-packages\django\template\loaders\base.py", line 24, in get_template
contents = self.get_contents(origin)
File "C:\Users\chris\Envs\koka\lib\site-packages\django\template\loaders\filesystem.py", line 23, in get_contents
with open(origin.name, encoding=self.engine.file_charset) as fp:
PermissionError: [Errno 13] Permission denied: 'C:\\Users\\chris\\koka\\bierviltje\\templates'
答案 0 :(得分:0)
我本人对其中很多东西还是陌生的。但是,我玩django-funky-sheets已有一段时间了,并且遇到了与您自己相同的错误。
我解决的方法是在我的应用目录中相关模板和templatetags文件夹下重新创建必要的文件。
我基本上使用了GitHub文件中的内容:https://github.com/trco/django-funky-sheets/tree/master/funky_sheets
例如,我在以下位置添加新文件:
然后,我像引用任何其他模板一样引用模板(取决于您如何在核心settings.py中定义静态网址)。对我来说,这看起来像{%include“ app / hot.html”%}。
请确保将hot.html文件中的{%include errors_template%}更改为{%include“ app / errors.html”%}。
我知道这不是最实用的解决方案,但它确实有效,而且当尝试将handontable与更复杂的视图合并时,查看模板的工作原理非常有用。