asaglimbeni / django-datetime-widget

Bootstrap django-datetime-widget is a simple and clean widget for DateField, Timefiled and DateTimeField in Django framework. It is based on Bootstrap datetime picker, supports both Bootstrap 3 and Bootstrap 2
Other
218 stars 128 forks source link

I get TypeError: 'undefined' is not a function (evalua ….) #28

Open dpeinado opened 10 years ago

dpeinado commented 10 years ago

Hello, thanks a lot for providing this kind of widget. I'm having a problem using this widget. I see the widget in the page with the icon. I push the icon and nothing occurs. I see in the debugger this error: TypeError: 'undefined' is not a function (evaluating '$("#f4f0d394302e4843a2f0863dd7c428ee").datetimepicker') global code (39, line 144)

I've tried to follow closely the example, but I do not know where the problem is. In the base template I have:

<link href="{% static 'css/bootstrap.min.css' %}" rel="stylesheet" media="screen">
<link href="{% static 'css/bootstrap-responsive.min.css' %}" rel="stylesheet">
 <!-- This file store project specific CSS -->
<link href="{% static 'css/project.css' %}" rel="stylesheet">
<!-- Use this to quickly test CSS changes in a template,
    then move to project.css -->
{% block extra_css %}{% endblock extra_css %}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>  
<script src="{% static 'js/jquery.ui.datepicker.js' %}"></script>
<script src="{% static 'js/bootstrap.min.js' %}"></script>

{{ form.media }}

Then in the template where these widgets are I have:

{% csrf_token %} {{ formset.management_form }} {% for miform in formset %} {{ miform.id}} {% if miform.instance.indicador.esIntervalo %} {{ miform.instance.indicador.nombre }}: {% else %} {% endif %} {% endfor %}
{{ miform.instance.indicador.nombre }}: Inicio Intervalo{{ miform.fecha1 }}Fin Intervalo{{miform.fecha2}} {{ miform.numero }} de {{ miform.total}}{{ miform.instance.indicador.nombre }}: {{ miform.valor|center:'4' }} {{miform.instance.indicador.unidad}}

The form for the formset is:

class InsIndicForm(forms.ModelForm):

valor = forms.FloatField(widget=forms.TextInput(attrs={'size':'5'}))

class Meta:
    model=InstanciaIndicador
    fields=('valor','fecha1','fecha2','numero', 'total')
    widgets = {
        'fecha1': DateTimeWidget(attrs={'id':"fecha1"}, usel10n = True),
        'fecha2': DateTimeWidget(attrs={'id':"fecha2"}, usel10n = True),
    }

Please, do you see where is the error?

Thanks in advance,

Diego.

kleinlieu commented 9 years ago

Hey Diego, looks like jQuery may not be defined. I haven't tried this solution yet, but you could try looking at the following link for a proposed solution: https://github.com/asaglimbeni/django-datetime-widget/issues/61

bartmika commented 9 years ago

+1 Same problem