Python Django进度条Djangoprogressbarupload

2024-03-29 14:10:37 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试使用这个模块'django progressbarupload'(https://github.com/ouhouhsami/django-progressbarupload)。我已经完全按照github页面的安装说明进行了操作,但是在Chrome或Firefox中都找不到上传栏。在

对于设置设置.py文件,我设置我的管理员py像这样:

## For the Model Admins for the File Upload classes ( Video and Audio )
from django.contrib import admin

## Get the forms
from django import forms

## Import the file models
from models import VideoFile
from models import AudioFile

## For the progress bar
class UploadAudioFileModelForm(forms.ModelForm):
    class Meta:
        model = AudioFile
class UploadVideoFileModelForm(forms.ModelForm):
    class Meta:
        model = VideoFile

## For the progress bar
class UploadAudioFileModelAdmin(admin.ModelAdmin):
    change_form_template = 'progressbarupload/change_form.html'
    add_form_template = 'progressbarupload/change_form.html'
    form = UploadAudioFileModelForm
    class Media:
        js = ("http://code.jquery.com/jquery.min.js",)
## For the progress bar
class UploadVideoFileModelAdmin(admin.ModelAdmin):
    change_form_template = 'progressbarupload/change_form.html'
    add_form_template = 'progressbarupload/change_form.html'
    form = UploadAudioFileModelForm
    class Media:
        js = ("http://code.jquery.com/jquery.min.js",)

admin.site.register(VideoFile, UploadVideoFileModelAdmin)
admin.site.register(AudioFile, UploadAudioFileModelAdmin)

这是我的上传模板:

^{pr2}$

这是我的基本.html以下内容:

{% load static %}
{% load progress_bar %}

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html lang="en">

<head>

        <link rel="stylesheet" type="text/css" href="{% static "css/base_style.css" %}">
        <title>{% block title %}Welcome!{% endblock %}</title>
        {% block additional_head_info %}{% endblock %}

        <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.min.js"></script>
        <script type="text/javascript" src="http://code.jquery.com/jquery-1.8.3.min.js"></script>

</head>

<body>

        <h1>Welcome to the Website!</h1>

        {% if not user.is_authenticated %}
        <a href="/accounts/login/?next=/">login</a> | <a href="/accounts/register/">register</a> | <a href="/">home</a>
        {% endif %}

        {% if user.is_authenticated %}
        <a href="/accounts/logout/?next=/">logout</a> | <a href="/">home</a> | <a href="/upload/">upload</a>
        {% endif %}

        {% block content_title %}{% endblock %}
        {% block content %}{% endblock %}
        {% block footer %}

        <hr>
        <img src="{% static "img/debian-logo.png" %}" alt="Tours Logo"/>
        <p>Thanks for visiting - more content coming soon....</p>
        {% endblock %}

</body>

</html>

以下是Django呈现后我的网页的来源:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html lang="en">
<head>
<link rel="stylesheet" type="text/css" href="/static/css/base_style.css">
<title>Upload your !</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.min.js"></script>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.3.min.js"></script>
</head>
<body>
<h1>Welcome to the '' Website!</h1>
<a href="/accounts/logout/?next=/">logout</a> | <a href="/">home</a> | <a href="/upload/">upload</a>
<h1>Upload Information -</h1>
<script type="text/javascript" src="../media/js/jquery.formset.js"></script>
<script type="text/javascript">
$(function() {
$('#upload_formset ul').formset({
addText: 'Add a new Stop',
deleteText: 'Remove this Stop'
});
})
</script>
<script type="text/javascript" src="../media/js/progress_bar.js"></script>
<form id="upload_formset" action="" method="POST" enctype="multipart/form-data"> <input type='hidden' name='csrfmiddlewaretoken' value='O6NmPrifvScHP9IUXJIdaf0wnlrGFQgU' />
<table>
<tr><th><label for="id_name"> Name:</label></th><td><input id="id_name" maxlength="100" name="name" type="text" /><br /><span class="helptext">My Awesome </span></td></tr>
<tr><th><label for="id_contact_email">Contact Email:</label></th><td><input id="id_contact_email" name="contact_email" type="text" /><br /><span class="helptext">John.Appleseed@gmail.com</span></td></tr>
<tr><th><label for="id_description"> Description:</label></th><td><textarea cols="40" id="id_description" name="description" rows="10">
</textarea></td></tr>
<tr><th><label for="id_website">Website:</label></th><td><textarea cols="40" id="id_website" name="website" rows="1">
</textarea><br /><span class="helptext">e.g. http://www.ptrackapp.com</span></td></tr>
<tr><th><label for="id_address">Address:</label></th><td><textarea cols="40" id="id_address" name="address" rows="1">
</textarea><br /><span class="helptext">e.g. 1234 Colorado Ave. Denver, Colorado 80201</span></td></tr>
</table>
<br><br/>
<table>
<input id="id_form-TOTAL_FORMS" name="form-TOTAL_FORMS" type="hidden" value="2" /><input id="id_form-INITIAL_FORMS" name="form-INITIAL_FORMS" type="hidden" value="0" /><input id="id_form-MAX_NUM_FORMS" name="form-MAX_NUM_FORMS" type="hidden" value="1000" />
<ul>
<p><label for="id_form-0-address"> Step:</label> <textarea cols="40" id="id_form-0-address" name="form-0-address" rows="1">
</textarea> <span class="helptext">Enter an Address for this  Stop</span></p>
<p><label for="id_form-0-description"> Step Description:</label> <input id="id_form-0-description" maxlength="250" name="form-0-description" type="text" /> <span class="helptext">Enter some Information about this Stop</span></p>
<p><label for="id_form-0-video"> Step Video File:</label> <input id="id_form-0-video" name="form-0-video" type="file" /> <span class="helptext">max. 42 megabytes</span></p>
<p><label for="id_form-0-audio"> Step Audio File:</label> <input id="id_form-0-audio" name="form-0-audio" type="file" /> <span class="helptext">max. 42 megabytes</span></p>
</ul>
<ul>
<p><label for="id_form-1-address"> Step:</label> <textarea cols="40" id="id_form-1-address" name="form-1-address" rows="1">
</textarea> <span class="helptext">Enter an Address for this  Stop</span></p>
<p><label for="id_form-1-description"> Step Description:</label> <input id="id_form-1-description" maxlength="250" name="form-1-description" type="text" /> <span class="helptext">Enter some Information about this Stop</span></p>
<p><label for="id_form-1-video"> Step Video File:</label> <input id="id_form-1-video" name="form-1-video" type="file" /> <span class="helptext">max. 42 megabytes</span></p>
<p><label for="id_form-1-audio"> Step Audio File:</label> <input id="id_form-1-audio" name="form-1-audio" type="file" /> <span class="helptext">max. 42 megabytes</span></p>
</ul>
</table>
<br><br/>
<progress id="progressBar" data-progress_bar_uuid="131a107d-49ac-4e30-b307-5097dd13e232" value="0" max="100" hidden></progress><script>upload_progress_url = "/progressbarupload/upload_progress"</script>
<input type="submit" value="Submit!">
</form>
<hr>
<img src="/static/img/debian-logo.png" alt=" Logo"/>
<p>Thanks for visiting - more content coming soon....</p>
</body>
</html>

页面加载,我可以上传我的文件,但我从来没有看到一个进度条。我也没有看到任何错误在FireBug加载任何脚本。。。有什么想法吗?谢谢!在


Tags: textnameformidforinputtypejs