On 20/04/2008, Berco Beute <[EMAIL PROTECTED]> wrote:
>
>  Using: Latest from trunk
>
>  I'm using a custom widget for datetimefields:
>
>  ======================================
>  #models.py
>  class Event(models.Model):
>     endDateTime = models.DateTimeField('Finish', blank=True,
>  null=True)
>
>
>  #forms.py
>  class EventForm(forms.ModelForm):
>     endDateTime = forms.DateTimeField(widget=DateTimeWidget)
>
>     class Meta:
>         model = Event
>
>  ======================================
>
>  But somehow the 'endDateTime' field is still required when rendering
>  the form and the label is 'endDateTime' instead of 'Finish'. Resetting
>  the app, syncing the db etc. doesn't help.
>
>  Any suggestions?

If you only want to change the widget type for a field you can just
modify the form
after creating it or do it in the __init__ method. This has the
benefit of not having
to repeat the label/required information in 2 places (model and form):


    #forms.py
   class EventForm(forms.ModelForm):

      def __init__(self, *args, **kwargs):
          super(EventForm, , self).__init__(*args, **kwargs)
          self.fields['endDate'].widget = DateTimeWidget()

     class Meta:
          model = Event


-- 
Phil Davis

--~--~---------~--~----~------------~-------~--~----~
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