You can use modelForm.
for example in you form.py file, you can do something like this:
class addstaff(forms.ModelForm):
class Meta:
model =new_staff
fields =('first_name', 'last_name', 'gender', 'date_of_birth')
and in your view.py you do something like this:
def newstaff(request):
if request.POST:
form =addstaff(request.POST)
if form.is_valid():
form.save()
return render_to_response("successful.html")
else:
form =addstaff
args={}
args.update(csrf(request))
args['form']=form
return render_to_response('addnewstaff.html', args)
Cheers
On Mon, Dec 7, 2015 at 6:54 AM, Gergely Polonkai <[email protected]>
wrote:
> Hello,
>
> you should use ModelForm; if the only problem you have is the CSS
> properties, you may assign custom CSS classes to your widgets, and use
> templates to render your fields individually.
>
> Best,
> Gergely
> On Dec 6, 2015 5:33 PM, "Teddy McZieuwa" <[email protected]> wrote:
>
>> Hi,
>> please, I am new to django, I just need to know to save to a database
>> while using 'forms.Form' utility and how does it know which database model
>> to use. I do not want to use the 'forms.ModelForm' because i would like to
>> customize, I don't want django giving me its default style form.
>> Please I really need help ASAP. Thank you.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> To post to this group, send email to [email protected].
>> Visit this group at http://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/b0474e0d-4cac-4b6f-8396-87208d4e0dc7%40googlegroups.com
>> <https://groups.google.com/d/msgid/django-users/b0474e0d-4cac-4b6f-8396-87208d4e0dc7%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CACczBUKsA0M7LStkf0JLQCCkD0C9gmRd3yBMBOXv7Ox-9uzk9w%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CACczBUKsA0M7LStkf0JLQCCkD0C9gmRd3yBMBOXv7Ox-9uzk9w%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/CAPCf-y7Lp6P5qMDk-ENM-fyZcYy272BV2dMSp511ybxO2dziXw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.