我想从一些数据集开始。当我这样做时,给我一个错误(init()得到了一个意外的关键字参数'user')。为什么?
if request.method == 'POST': # If the form has been submitted...
form = UcitelZmenaForm(request.POST) # A form bound to the POST data
if form.is_valid(): # All validation rules pass
# Process the data in form.cleaned_data
form = UcitelZmenaForm(request.POST)
form.save()
return HttpResponseRedirect('/hlavni_stranka/') # Redirect after POST
else:
form = UcitelZmenaForm(user=request.user) # An unbound form
class Clovek(models.Model):
user=models.OneToOneField(User)
mesto=models.CharField(max_length=100, blank=True)
class Ucitel(Clovek): #pridat pote classu tridniho ucitele
predmety=models.ManyToManyField(Predmety) #manyToManyField
class UcitelZmenaForm(ModelForm):
class Meta:
model = Ucitel