On Feb 21, 10:03 am, Alex Gaynor <alex.gay...@gmail.com> wrote:
> On Sat, Feb 21, 2009 at 7:48 AM, Chris <chriss...@gmail.com> wrote:
>
> > Is it a good idea to reuse admin's JS datepicker widget in other apps,
> > and if so, what's the best way?
>
> > I'm using django.contrib.admin.widgets.AdminDateWidget in my form, and
> > I've added these JS tags to my template:
>
> > admin/DateTimeShortcuts.js
> > admin/RelatedObjectLookups.js
> > calendar.js
> > core.js
>
> > This gets the datepicker icon to show up, but clicking it does
> > nothing. I'm assuming I probably need some CSS includes as well, but
> > I'm not sure which CSS files to include, or if the admin style sheets
> > will start to conflict with my apps style sheets.
>
> > Regards,
> > Chris
>
> If you use the admin datepicker in your form, instead of explicitly listign
> the JS to use simply put {{ form.media }} in the head of your HTML, the
> widget knows which JS and CSS it uses, so the form will put the<script> and
> <link> tags in appropriately.
>
> Alex

Thanks, but this doesn't seem to work. Removing my hard-coded JS
includes, and replacing them with {{ form.media }} only generates:

<script type="text/javascript" src="/admin_media/js/calendar.js"></
script>
<script type="text/javascript" src="/admin_media/js/admin/
DateTimeShortcuts.js"></script>

Which breaks in the absence of core.js. Even if it included the
correct JS, it's still missing CSS, so it still wouldn't display
correctly.

Chris

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to