I believe the idea is that if you override a field in your custom form, you
are then working off the default implementation of a field, which doesn't
include any of the niceties that the admin has added for you.

keith


On Fri, Oct 17, 2008 at 10:34 AM, mthorley <[EMAIL PROTECTED]> wrote:

>
> Thanks Keith, that worked perfectly. Can you tell me the reason I have
> to use the admin widgets and can't use regular form widgets as I might
> with any other form?
>
>
>
> On Oct 17, 7:11 am, "Keith Eberle" <[EMAIL PROTECTED]> wrote:
> > I had a project where I needed to set the initial value to the current
> > week's week ending date (Sat), so I needed a custom form too.  I used the
> > AdminDateWidget, but I think this will be the correct widget for your
> needs.
> >
> > # import the widgets
> > from django.contrib.admin import widgets
> >
> > # use the widget on this line
> > date = forms.DateTimeField(widget=widgets.AdminSplitDateTime)
> >
> > keith
> >
> > On Thu, Oct 16, 2008 at 6:23 PM, mthorley <[EMAIL PROTECTED]> wrote:
> >
> > > Hello, I'm building a custom admin site with a custom form and the
> > > datetime widget shows up as a text input. When I set the widget for
> > > the date field to textarea I get a textarea, but when I set it to
> > > datetime, I get I text input. I also tried not specifying any widget
> > > and I still get just a text input.
> >
> > > Can some one please tell me why or how to fix it?
> >
> > > Thanks much
> > > --
> > > matthew
> >
> > > from django import forms
> > > from django.contrib import admin
> > > from colorcode.trainertools.models import Workshop
> >
> > > class WorkshopForm(forms.Form):
> > >  name = forms.CharField(max_length=64)
> > >  date = forms.DateTimeField(widget=forms.DateTimeInput())
> > >  code = forms.CharField()
> >
> > > class WorkshopAdmin(admin.ModelAdmin):
> > >  def get_form(self, request, obj=None, **kwargs):
> > >    return WorkshopForm
> >
> > > trainers_admin = admin.sites.AdminSite()
> > > trainers_admin.register(Workshop, WorkshopAdmin)
> >
> >
> >
>

--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to