Showing admin-style forms on regular user forms?

2 views
Skip to first unread message

shredwheat

unread,
Mar 26, 2006, 6:39:33 PM3/26/06
to Django users
I'm just getting started with Django. Went through the tutorials for
getting a simple form and validation on the user site. I have a time
and date field shown, but they are plain text entry form widgets. I was
hoping they would be all decorated out like the time and date fields on
the admin pages.

Is it possible to just use one of the admin generic views anywhere in
the site?

James Bennett

unread,
Mar 26, 2006, 7:26:54 PM3/26/06
to django...@googlegroups.com
On 3/26/06, shredwheat <pe...@shinners.org> wrote:
> I'm just getting started with Django. Went through the tutorials for
> getting a simple form and validation on the user site. I have a time
> and date field shown, but they are plain text entry form widgets. I was
> hoping they would be all decorated out like the time and date fields on
> the admin pages.

No, the JavaScript that does that is currently coupled to other
JavaScript stuff used in the admin. I'm working on porting all of our
JavaScript to the Dojo toolkit, and one of my goals is to make things
like the fancy admin date/time widgets more easily reusable, but I
don't have any kind of timeframe on when that will hit trunk.

> Is it possible to just use one of the admin generic views anywhere in
> the site?

You'd probably have to hack on them a bit.


--
"May the forces of evil become confused on the way to your house."
-- George Carlin

tonemcd

unread,
Mar 26, 2006, 8:14:04 PM3/26/06
to Django users
Check this out -
http://groups.google.com/group/django-users/browse_frm/thread/3328829f1ed7f788/a980f983c5fc1bad

It's very rushed, as I was on the way to the airport and just wanted to
get the post made before I forgot it, but it does work...

Cheers,
Tone

shredwheat

unread,
Mar 27, 2006, 1:56:07 AM3/27/06
to Django users
This is some amazing work, thank you! I have the magic widgets in my
form now, it was quite simple to do following your work. Looks like I
still need to bless them with some CSS because they are semi rancid
looking. But it all works as needed. Still using the generic
update_object view to generate the form.

As a recap to others. These were the steps I took:

1) add an entry to my site's urlpatterns
(r'^jsi18n/$', 'django.views.i18n.javascript_catalog', {'packages':
'django.conf'}),

2) add the following code to the start of the "form" template page.
<script type="text/javascript" src="/jsi18n/"></script>
<script type="text/javascript" src="/media/js/core.js"></script><script
type="text/javascript"
src="/media/js/admin/RelatedObjectLookups.js"></script><script
type="text/javascript" src="/media/js/calendar.js"></script><script
type="text/javascript"
src="/media/js/admin/DateTimeShortcuts.js"></script>

Reply all
Reply to author
Forward
0 new messages