Monday, July 25, 2011

__init__() got an unexpected keyword argument 'city'

Hi I am facing this problim from few days..tried a lot to correct it
but everytime i failed..Please Help...

I have created a simple form to store few field values in my
database.. It was working until i used the forms.py.. when i developed
this with forms.py i got this error

__init__() got an unexpected keyword argument 'city'

Now i removed the forms.py but it still shows the same error.. But i
want to learn forms so how could i correct it ..Thanks in advance

===============
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)
print "kkkkkkkkkkkkkkkkkkkkkkkkkkkk"


==========================
views.py
==========================

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')


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 "000000000000000000000000000000---"
save_record
save_record.save()
print save_record.id
return render_to_response('student_form.html',
{'student' :save_record.id})

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate