On Mon, Jul 27, 2009 at 7:52 AM, AKK<andrewkenyon...@gmail.com> wrote:
>
> Is there a way to do this or should i create my own form manually?
>
> Andrew
>
> On Jul 27, 12:15 am, AKK <andrewkenyon...@gmail.com> wrote:
>> Hi, I have a form based on a model which allows users to add comment.
>> A comment is made up of the comment is about, the body, the date and
>> time and also who made the comment.
>>
>> I am mainly interested in the datetime and user fields. What i would
>> like to know is how i can automatically have these entered. For the
>> username i  know if i created the form myself i could have a hidden
>> field with the value of {{ user.username }}. I'm not sure how i could
>> automatically specify the time. But since the form is created
>> automatically i could do with some help.
>>
>> Thanks,
>>

The Django documentation set contains a [1]document
titled "Creating forms from models" completely devoted to
the topic. I'd recommend to read it if you haven't done so
yet and if you are in a hurry as you seems to be.

That document shows, somewhat prominently, a
[2]section named "Using a subset of fields on the form"
that describes the techniques (and the relevant
caveats) for doing what you describe.

1. http://docs.djangoproject.com/en/dev/topics/forms/modelforms/
2. 
http://docs.djangoproject.com/en/dev/topics/forms/modelforms/#using-a-subset-of-fields-on-the-form

HTH

-- 
Ramiro Morales
http://rmorales.net

PyCon 2009 Argentina - Vie 4 y Sab 5 Septiembre
Buenos Aires, Argentina
http://ar.pycon.org/2009/about/

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

Reply via email to