samuelcolvin的djangbootstrap3datetimepicker在单击输入字段时不显示日历

2024-04-18 18:55:56 发布

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

我尝试使用samuelcolvin's django-bootstrap3-datetimepicker,其中它基于Eonasdan's bootstrap-datetimepicker,但是从nkunihiko's django-bootstrap3-datetimepicker分叉来显示日历,这样用户就可以选择日期和时间并提交它。我遇到的问题是,当我像在demo website中那样,在字段或右键上单击日历图标时,它不会显示任何内容。在

我还必须将来自repo的widgets.py添加到我的项目中,因为它给了我一个名为bootstrap3的无模块_日期时间.widgets错误。在

谢谢你的帮助

这是我在我的models.py中所拥有的:

class Production(TimeStampedModel):

        #Some other code.....

        scheduled_date = models.DateTimeField(null=True, blank=True)
        fully_produced_date = models.DateTimeField(null=True, blank=True)

forms_schedule.py

^{pr2}$

views.py

def episodeschedule(request):

    title = 'Podcast'
    title_align_center = True
    subtitle = 'Setup | Add Episode'
    subtitle_align_center = True
    form = ScheduleForm(request.POST or None)
    context = {
        "title": title,
        "subtitle": subtitle,
        "form": form
    }

    if form.is_valid():

        instance = form.save(commit=False)

        scheduled_date = form.cleaned_data.get("scheduled_date")
        fully_produced_date = form.cleaned_data.get("fully_produced_date")

        instance.scheduled_date = scheduled_date
        instance.fully_produced_date = fully_produced_date

        instance.user = request.user

        instance.save()

        return render(request, "forms_schedule.html", context)

    else:

            return render(request, "forms_schedule.html", context)

forms_schedule.html

{% extends "base.html" %}
{% load crispy_forms_tags %}


{% block content %}

<div class="progress">
  <div class="progress-bar progress-bar-striped progress-bar-success active" role="progressbar" aria-valuenow="100" aria-valuemin="0" aria-valuemax="100" style="width: 100%">
    <span class="sr-only">100% Complete</span>
  </div>
</div>

<div class="panel panel-default box-shadow--16dp col-sm-6 col-sm-offset-3">
<div class="panel-body">

<div class='row'>
<div class='col-sm-12'>

{% if title %}
<h1 class='{% if title_align_center %}text-align-center{% endif %}'>{{ title }}<!-- : {{ get.clientsetup.company_name }} --></h1>
{% endif %}
{% if subtitle %}
<h3 class='{% if subtitle_align_center %}text-align-center{% endif %}'>{{ subtitle }}</h4>
{% endif %}

<h5>Schedule</h5>

<form method='POST' action=''>{% csrf_token %}
{{ form|crispy }}

<hr/>

<input class='btn btn-info box-shadow--6dp' type='submit' value='Save' />
<p>
<p>
<a class="btn btn-primary box-shadow--6dp" href="{% url 'dashboard' %}" role="button"><i class="fa fa-upload" aria-hidden="true"></i>&nbsp SCHEDULE EPISODE</a>

</form>
</div>
</div>

</div>
</div>

{% endblock %}

Tags: divformtruedateiftitlerequestforms
1条回答
网友
1楼 · 发布于 2024-04-18 18:55:56

在设置.py在

在已安装的应用程序中添加“Bootstrap3_datetime”

模板

在htmlhead标记中添加以下行

{%block header%} {%load static%}

   <link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap /3.0.0 css/bootstrap.css">  

   <link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-theme.css">

   <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.js"></script>

   <script src="//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.js"></script>

{{窗体.媒体}} {%endblock%}

相关问题 更多 >