On Mon, May 9, 2011 at 10:55 AM, Kevin Miller <kevinvani...@gmail.com> wrote: > Dear all, > > I am new to django but is in the process of building my first website. I have > been ok for a while as I am not new to programming in python. However, I have > one problem that I cannot figure out the proper way to do it. I want to use > ModelForm but have a DateTime Field. I can do it without using a ModelForm but > I think using the ModelForm is the proper way to do it.
What's the problem with the DateTimeField in a model? > Can someone show me a small example of using ModelForm with DateTime field? > How can can the DateTime field me displayed in django templates? in your models.py: class Foo(models.Model): datetime = models.DateTimeField() class FooForm(forms.ModelForm): class Meta: model = Foo in your views.py: def bar(request): form = FooForm() return render_to_response("bar.html", {"form": form}) in template bar.html: {{ foo }} There's absolutely nothing special here :) . If you couldn't understand some of the code, then you should read the documentation . http://docs.djangoproject.com/en/dev/topics/forms/modelforms/ -- 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.