These are chat archives for django/django

19th
Jun 2016
Robin Ury
@teddy-error
Jun 19 2016 12:44
ahoy
QbasicFan
@QbasicFan
Jun 19 2016 14:38

how I get values from a form ?
In my html file I use a couple of input boxes ... It is a registration sort of form , the goal is to save the data entered into the DB
My view look like this :

a = MyTable( field1 = request.POST.get([value of name field 1 from the input box] , '') ,
... ,
fieldn = request.POST.get([value of name field n from the input box] , ''))
a.save()

No error but the table gets populated but with empty values ...

Filip Figiel
@megapctr
Jun 19 2016 14:44
@QbasicFan you could use django.forms.Form for that
form = MyForm(data=request.POST)
if form.is_valid():
  print form.cleaned_data
also consider using a FormView, it makes building complex views much easier! http://ccbv.co.uk/
QbasicFan
@QbasicFan
Jun 19 2016 14:50
@megapctr thanks
David Weir
@satdav
Jun 19 2016 21:37
Is good you have a channel on here I am a fan of this PS one of the organisations I volunteer for makes sites using Django