Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4025034
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:47:46+00:00 2026-05-20T10:47:46+00:00

been scratching my head. I’ve followed the examples to use a jquery datepicker for

  • 0

been scratching my head. I’ve followed the examples to use a jquery datepicker for my datefield in my form. Here are my code (note:indentation are correct in my code):

from django import forms
from django.contrib.admin.widgets import FilteredSelectMultiple
from myproject.customUsers.models import SchoolClass#,Student
from django.contrib.auth.models import User
from myproject.widgets import CalendarWidget

    class ConsentFormTpl(forms.Form):
        title =  forms.CharField()
        message = forms.CharField()
        deadline = forms.DateField(widget=CalendarWidget)
        availClass  = forms.ModelChoiceField(queryset=SchoolClass.objects.all(),empty_label="None")
        students = forms.ModelMultipleChoiceField(queryset=User.objects.filter(groups__name='Students'),widget=FilteredSelectMultiple("Students",is_stacked=False))

In my widgets file, I have:

class CalendarWidget(forms.DateInput):
    class Media:
        css = {
               'all':('css/ui-darkness/jquery-ui-1.8.9.custom.css',),
        }
        js = ('js/jquery-ui-1.8.9.custom.min.js',)

Finally in my template I use {{form.media}}. Strangely, the css and js files for CalendarWidget did not appear in my html. (the files for FilteredSelectMultiple are there). I checked through the shell it seems already:

>>> from django import forms
>>> from myproject.widgets import CalendarWidget
>>> class C(forms.Form):
...    title = forms.DateField(widget=CalendarWidget)
... 
>>> c=C()
>>> print c.media
<link href="http://xyz.com/media/css/ui-darkness/jquery-ui-1.8.9.custom.css" type="text/css" media="all" rel="stylesheet" />
<script type="text/javascript" src="http://xyz.com/media/js/jquery-ui-1.8.9.custom.min.js"></script>

template:

{% extends "base.html" %}
{% block content %}
<script type="text/javascript">

        $(document).ready(function(){
                //some stuff here
                        })

            }

            //When user change classes, load new set of students
            $("select#id_availClass").change(function(){
                getStud( $(this).val() );
            })

            $("#id_deadline").datepicker();

            // Loads initial set of students when form loads
            getStud(-1);

        })
</script>
<link rel="stylesheet" type="text/css" href="http://xyz.com/media/admin/css/base.css" />
<link rel="stylesheet" type="text/css" href="http://xyz.com/media/admin/css/forms.css" />
<script type="text/javascript" src="/admin/jsi18n/" />
<script type="text/javascript" src="/media/admin/js/core.js" />
{{ form.media }}
<form action="" method="post">{% csrf_token %}
    {{ form.as_p }}
    <input type="submit" name="yes" value="Submit" />
</form> {% endblock %}

Update:I managed to print the form media out before pushing it into render_to_response. The files are there!

form = ConsentFormTpl()
        print form.media

    return render_to_response('consent_form/consent_form2.html',{'form':form},context_instance=RequestContext(request))

Any pointers people?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T10:47:47+00:00Added an answer on May 20, 2026 at 10:47 am

    Ah, thanks to @seitaridis, I managed to find out where my error was. I did not specify the doctype, and ` wasn’t allowed. Gosh, I am embarrassed by such a simple mistake.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.