views:

21

answers:

1

I have an 'order' Model:

class Order(models.Model):
 date_time=models.DateTimeField()
 # other stuff

And I'm using Django ModelForm class to render a form, but I want to display date and time widgets separately. I've came up with this:

class Form(forms.ModelForm): 
 class Meta:
  model = Order
  exclude = ('date_time',)
 date = forms.DateField()
 time = forms.TimeField()

The problem is that I want to put these fields somewhere between 'other stuff'

A: 

You can use fields = [ ..., 'date', 'time', ... ] on Meta class of your form. (http://docs.djangoproject.com/en/dev/topics/forms/modelforms/#changing-the-order-of-fields)

Łukasz Korzybski