Hi All.. I am New to Django, I am trying to develop a page with few fields and want to store them in database..I am acchiving this without using forms by writing a long code in my .html file.. I want to do it with forms.py which would minimize my code and i ll also acheive loose coupling.. When I am using forms.py in my Application it shows a good form design in browser but when press the submit button it gives the below error
__init__() got an unexpected keyword argument 'city' How ever If i do it without using forms then it works and store data into my database.. Please Help Me..I am Fed up from last 3 days solving it.. Thanks In Advance My Code For views.py ================= from django.http import HttpResponse from django.shortcuts import render_to_response from school.student.models import * from django import forms from school.student.forms import * def new_form(request): form = Student(request.GET) ## form = Student() # form = Student( # initial={'address': 'Pune, Maharashtra \n411048!', 'city' : 'Pune'} # ) return render_to_response('student_form.html', {'form' :form}) def inserted(request): # if 'name' in request.GET: print "00000000000000000000",request.GET # form = ContactForm(request.GET) roll_no = request.GET['roll_no'] name = request.GET['name'] city = request.GET['city'] country = request.GET['country'] classes_id = request.GET['classes_id'] print "+++++++++++",request.GET sex = request.GET["sex"] save_record = Student(roll_no = roll_no, name = name, city = city , sex = sex, country=country, classes_id = classes_id) print "00000000000000000000000000000000000000000000000---",save_record save_record.save() print save_record.id return render_to_response('student_form.html', {'student' :save_record.id}) ============================================= Forms.py ======== from django import forms class Student(forms.Form): roll_no = forms.IntegerField(required = False) name = forms.CharField(max_length=20) address = forms.EmailField(required=False ,widget=forms.Textarea,label='Residential address') city = forms.CharField(required=False) country = forms.CharField(max_length=50) sex = forms.CharField(max_length=50) classes_id = forms.IntegerField(required = False) subject = forms.EmailField(required = False) ============================================= Student_form.html -=-============ <body> <!-- {% if not student %} --> <!-- <form action="/inserted/" method="get"> --> <!-- <table border = "1"> --> <!-- <tr> --> <!-- <td> Roll Number :- </td> --> <!-- <td> <input type="text" name="roll_no"> </td> --> <!-- </tr> --> <!-- <tr> --> <!-- <td> Name :- </td> --> <!-- <td> <input type="text" name="name"> </td> --> <!-- </tr> --> <!-- <tr> --> <!-- <td> City :- </td> --> <!-- <td><input type="text" name="city"> </td> --> <!-- </tr> --> <!-- <tr> --> <!-- <td> Country :- </td> --> <!-- <td> <input type="text" name="country"> </td> --> <!-- </tr> --> <!-- <tr> --> <!-- <td>Class :- </td> --> <!-- <td><input type="text" name="classes_id" value= 1></td> --> <!-- </tr> --> <!-- <tr> --> <!-- <td>Sex :- </td> --> <!-- <td> --> <!-- <input type="radio" name="sex" value="male" /> Male<br /> -- > <!-- <input type="radio" name="sex" value="female" /> Female --> <!-- </td> --> <!-- </tr> --> <!-- </table> --> <!-- <p></p> --> <!-- <input type="submit" value="Store Data"> --> <!-- <INPUT TYPE="button" onClick="/inserted/"> --> <!-- </form> --> <!-- <form action="" method="post"> --> <!-- <div class="field"> --> <!-- {{ form.subject.errors }} --> <!-- <label for="name">Subject:</label> --> <!-- {{ form.subject }} --> <!-- </div> --> <!-- </form> --> <!-- {% endif %} --> <!-- {% if student %} --> <form action="/new_form/" method="get"> <b>You Have Successfully Inserted One Record..</b><p></p> <b>Press Button To Insert A New Record</b> <p> <input type="submit" value="Fill One More Name"> </form> <!-- {% endif %} --> <form action="/inserted/" method="get"> <table> {{ form.as_table }} </table> <input type="submit" value="Submit"> </form> </body> -- 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.