Open sidd-shah opened 10 years ago
It started working by itself, still can't figure out though what was the reason, would be great if someone can throw some light on it
Was it a Python error or a Javascript error? Looks like JS I guess but your formatting is a little casual :)
Agree with Michael, looks like a JS error, if you could tell us where there error was thrown we would be able to debug further. I guess since you got it working it could be closed now.
I am having exactly the same problem. I have just installted the app within my Django project and, when I try to load the page, I get the same error:
\ website/settings.py
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'allauth',
'allauth.account',
'session_security',
'leaflet',
'periodically',
'rpc4django',
'rest_framework',
'django_extensions',
'south',
'datetimewidget',
# ... and some more that I do not list
)
\ forms.py:
from django import forms as django_forms
from datetimewidget import widgets as datetime_widgets
from services.leop.models import launch as launch_models
class LaunchForm(django_forms.ModelForm):
class Meta:
model = launch_models.Launch
fields = ('identifier', 'date')
widgets = {
'date': datetime_widgets.DateTimeWidget(
usel10n=True, bootstrap_version=3
)
}
The error that I am getting is a Javascript error: when jQuery tries to create the component, it cannot find the function (take a look at the attached screenshot).
What am I doing wrong?
If it's the jquery datetimepicker() function it can't find I suspect the following isn't being included on the page anywhere.
<link href="/site_media/static/css/datetimepicker.css" type="text/css" media="all" rel="stylesheet" />
<script type="text/javascript" src="/site_media/static/js/bootstrap-datetimepicker.js"></script>
Try adding them to the template and see if that fixes it.
Yes, you are right. I made a mistake and I did not include those files.
Step 3 of basic configuration does say it but it is easy to miss - I had the same problem earlier today :) I think the reason it is in configuration and installation is that you should really only include it on pages where you are actually using the widget.
Actually, if you read carefully the HTML code, at least in my opinion, it looks like that code is meant to include "bootstrap" dependencies and not "bootstrap-datetimepicker"... that was the problem that I had: I read the section and I thought that I only would have to include bootstrap js/css files... it was weird at first, but I decided to stick to the manual... please correct me if I am wrong.
Sorry, yes you're right, you shouldn't have to include the css/js directly as long as you include {{ form.media }}
somewhere in your template.
I was probably having problems because I was using the widgets without a form and I just include
{% if form %}{{form.media}}{% endif %}
in my base template.
I have been trying to get the widget running but the it keeps giving the above error. Please help. Form:
class BestQuoteQueryForm(forms.ModelForm): class Meta: model = BestQuoteQuery fields = ('email', 'name', 'number', 'additional_requirement','enquiry_for_date','event_type','no_of_guests','event_timing_start','event_timing_end') widgets = { 'event_timing_start':TimeWidget(), 'event_timing_end':TimeWidget(), }
HTML
<scri[t src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js">
"