Django:弹出消息没有显示使用Bootbox

时间:2016-10-07 06:14:07

标签: javascript django twitter-bootstrap bootbox

我正在尝试显示一个Bootbox,它使用自举模式,并显示一些已定义的消息,这些消息已经显示常规消息,只要点击一些引导按钮但到目前为止没有成功。

这是我在base.html文件中实现的代码,用于显示没有弹出窗口的消息:

{% if messages %}
    {% for message in messages %}
        <div class="alert alert-{{ message.tags }}">{{ message }}</div>
    {% endfor %}
{% endif %}

现在,我不想再使用它了,想要使用Bootbox库。这就是我在javascript.html文件中实现它的方式:

{% load staticfiles %}
<!-- Bootstrap core JavaScript
    ================================================== -->
    <!-- Placed at the end of the document so the pages load faster -->
    <script src="{% static 'js/jquery.formset.js' %}"></script>
    <script src="{% static 'js/moment.js' %}"></script>
    <script src="{% static 'js/transition.js' %}"></script>
    <script src="{% static 'js/collapse.js' %}"></script>
    <script src="{% static 'js/bootstrap.js' %}"></script>
    <script src="{% static 'js/bootstrap-datetimepicker.min.js' %}"></script>
    <script src="{% static 'js/bootstrap-filestyle.min.js' %}"></script>
    <script src="{% static 'js/bootbox.min.js' %}"></script>
    <script src="{% static 'js/jquery-3.0.0.js' %}"></script>

<script>

       $(document).ready(function(){
           $('.btn').on('click', function(){
               bootbox.alert(message);
           });
       });

</script>

这是views.py中提取message的代码:

class EpisodeActionView(ProductionRequiredMixin, RedirectView):
    pattern_name = 'podfunnel:dashboard'

    def get(self, request, *args, **kwargs):

        if self.podcast.is_expired():
            messages.warning(request, 'Your account is mark as expired. Please contact your account manager for '
                                      'renewal options.')
        else:

            if self.production.base_production_produced:
                if not self.production.asynch_publish_in_process:
                    # Publish
                    self.production.asynch_publish_in_process = True
                    self.production.save()
                    podfunnel_full_publish_production.delay(self.production)
                    messages.success(request, 'Production queued for Output and Publishing. Please check later')
                else:
                    messages.warning(request, 'Production was already queued for publishing but not yet ready. '
                                              'Please check later')
            elif not self.production.base_production_started:
                # Produce
                podfunnel_asynch_produce_production.delay(self.production)
                messages.success(request, 'Production queued for Auphonic processing. Please check later')
            else:
                # Update from Auphonic
                success, message = podfunnel_update_production_from_auphonic(self.production)
                messages.add_message(request, messages.SUCCESS if success else messages.WARNING, message)

        return super(EpisodeActionView, self).get(request)

不胜感激任何建议。感谢

---- ---- UPDATE

我的css.html

{% load staticfiles %}
    <!-- Bootstrap core CSS -->
    <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css">
    <link href="{% static 'css/bootstrap.css' %}" rel="stylesheet">
    <link href="{% static 'css/navbar-static-top.css' %}" rel="stylesheet">
    <link href="{% static 'css/bootstrap.custom.css' %}" rel="stylesheet">
    <link href="{% static 'css/bootstrap-datetimepicker.css' %}" rel="stylesheet">
    <link href="{% static 'css/podfunnel_custom.css' %}" rel="stylesheet">
    <link rel="stylesheet" href="{% static "charsleft_widget/css/charsleft.min.css" %}" type="text/css" media="screen"/>

0 个答案:

没有答案