0
Django的JFU是Django的jQuery的文件上傳(https://github.com/Alem/django-jfu)TemplateDoesNotExist(約JFU)
jfutags.py:
from django.core.context_processors import csrf
from django.core.urlresolvers import reverse
from django.template import Library, Context, loader
register = Library()
@register.simple_tag(takes_context = True)
def jfu(
context,
template_name = 'jfu/upload_form.html',
upload_handler_name = 'jfu_upload',
*args, **kwargs
):
"""
Displays a form for uploading files using jQuery File Upload.
A user may use both a custom template or a custom upload-handling URL
name by supplying values for template_name and upload_handler_name
respectively.
Any additionally supplied positional and keyword arguments are directly
forwarded to the named custom upload-handling URL.
"""
context.update({
'JQ_OPEN' : '{%',
'JQ_CLOSE' : '%}',
'upload_handler_url': reverse(
upload_handler_name, args = args, kwargs = kwargs
),
})
# Use the request context variable, injected
# by django.core.context_processors.request,
# to generate the CSRF token.
context.update(csrf(context.get('request')))
t = loader.get_template(template_name)
return t.render(Context(context))
在我topic.html,我用它的標籤以這種方式,我想topic.id
到作爲參數傳遞給name ='topic_pic_upload'的URL。
{% load jfutags %}
{% jfu 'upload_form.html' 'topic_pic_upload' topic.id}
然而,事實證明
TemplateDoesNotExist at /topic/122/
forum/topic.html
當它顯示
Using loader django.template.loaders.app_directories.Loader:
C:\FairyBBS\account\templates\forum\topic.html (File does not exist)
C:\FairyBBS\forum\templates\forum\topic.html **(File exists)**