Use JQuery Calendar in ModelForm

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<!-- Given this model:

class Shipment(models.Model):
	ordernum = models.CharField('Order Number', max_length=10)
	scheduled_date = models.DateField('date scheduled')

	def __unicode__(self):
		return self.ordernum

	class Meta:
		ordering = ["-ordernum"]

-->

<!--Base Site -->


<!DOCTYPE html>
<html>
<head>{% block head %}{% endblock %}
<link rel="stylesheet" type="text/css" href="http://jquery-ui.googlecode.com/svn/tags/latest/themes/base/jquery-ui.css" media="all" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
<script type="text/javascript">
    $(function() {
        $('.vDateField').datepicker();
    });
</script>
{% block scripts %}{% endblock %}
<title>Site Name</title>

</head>
<body bgcolor="#1E0F0F">
<div id="engrave"><h1><font color="white">Site Name</font></h1></div>
<div id="content">
<h2>{% block title %}{% endblock %}</h2>
{% block content %}{% endblock %}<br />
<div align="right"><p><i>Site powered viciously by OWLad</i></p></div>
</div>
</body>
</html>

<!-- Then create a page that uses the model: -->

{% extends "base_site.html" %}
{% block title %}Add Shipment{% endblock %}
{% block content %}
<p>{{ messsage }}</p>
<form method="post">
{{ addform.as_p }}
<input type="submit" value="Create Shipment" />
</form>
{% endblock %}

More like this

  1. Django Jalali Calendar Widget by behrooznobakht 3 years, 10 months ago
  2. TinyMCE Widget by semente 4 years, 7 months ago
  3. Datetime widget by pigletto 6 years, 7 months ago
  4. Add a CSS class to every field indicating what kind of field it is by ramen 3 years, 9 months ago
  5. DateTimeWidget using JSCal2 by ramusus 4 years, 9 months ago

Comments

(Forgotten your password?)