On Thu, Feb 5, 2009 at 2:24 AM, Neeru <neer...@gmail.com> wrote:

>
> comming to my problem...
>
> as far this code works fine. there is no error in this.
> I able to display the form text fields in the form when i use the
> url.
> In views.py file,
>        how can i access the separate field values that have been
> submitted from html form file,
>

You don't seem to have any code that even attempts to do this, all you do is
create the form, call is_valid(), and if that works attempt to save it.  If
you want to access individual fields while handling the request, how to do
that is shown here:

http://docs.djangoproject.com/en/dev/topics/forms/#processing-the-data-from-a-form



>
> and submission is done by the object.save() function is used to save
> the table.
>
> when i press submit button, just simple go to index page. nothing is
> entered into the table record.
>
>
I don't understand how you are not seeing errors.  The view code you posted
is:

def loanform(request):
   if request.method == 'POST':
       tr = loanform(request.POST)
       if tr.is_valid():
           tr.save()
           return HttpResponseRedirect('/index')
   else:
       tr = loanform()
   return render_to_response('loan.html', {'form': tr})

where in a different file you have a form declared as:

class loanform(forms.Form):

There are (at least) a couple of problems here.  First, you are using the
same name for your view function and your form class.  When the Python
compiler gets to your def loanform(request), any previous class loanform you
may have imported is forgotten.  So, within your loanform view, "tr =
loanform(request.POST)" results in the loanform view calling itself
recursively.  Only request.POST won't have a 'method' attribute, so that
call should result in an AttributeError on line 2 of the loanform view.

Assuming you fix the name problem (you also might want to read the Naming
Conventions section of PEP 8 http://www.python.org/dev/peps/pep-0008/ and
consider adopting it's recommendations), a second problem is that your form,
as defined, doesn't have a save() method.  Only ModelForms (which I pointed
to the doc for earlier) have save() methods.  Regular forms have no
association with model objects so there is nothing meaningful for a save()
method to do.

Karen

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