Hi, 

So you want a form to store a news student in your DB right ?!
If that's correct you also have a Model for the Student so you could simply use 
a ModelForm instead of a Form.

Example:

class Buchung(models.Model):
    Mitarbeiter = models.IntegerField(max_length=3)
    Produkt = models.ForeignKey(Produkte)
    Datum = models.DateField()
    Aktivitaet = models.ForeignKey(Aktivitaeten, blank=True)
    Minuten = models.PositiveIntegerField(max_length=2)

class BuchungChangeForm(ModelForm):
    class Meta:
        model = Buchung

BuchungChangeForm should now be a form that has all the fields for Buchung.


. . . . . . . . . . . . . . . . . . . . . . . . . .
Patrick Szabo
 XSLT Developer 
LexisNexis
Marxergasse 25, 1030 Wien

mailto:[email protected]
Tel.: 00431 534521573 
Fax: +43 (1) 534 52 - 146 


-----Ursprüngliche Nachricht-----

Von: [email protected] [mailto:[email protected]] Im 
Auftrag von Showket Bhat
Gesendet: Montag, 25. Juli 2011 10:23
An: Django users
Betreff: __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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to