TypeError an invalid keyword argument for this function












0















I am new to Python trying to make forms field and have a problem.
My forms shows correctly at html but when I am trying to submit data and save it to a database, but I have an error:




TypeError at /srdb/

'send_date' is an invalid keyword argument for this function




Here is my code:



models.py



class Srdb(models.Model):
send_date = models.DateField()
send_weight = models.IntegerField(default=0, validators=[MaxValueValidator(10000), MinValueValidator(100)])
track_code = models.CharField(default=None, blank=False, max_length=20)
send_index = models.IntegerField(default=None, blank=False,
validators=[MaxValueValidator(999999), MinValueValidator(100000)])
sender_fullname = models.CharField(default=None, blank=False, max_length=150)
sender_dob = models.DateField()
sender_adress = models.CharField(default=None, blank=False, max_length=400)

receiver_index = models.IntegerField(default=None, blank=False,
validators=[MaxValueValidator(999999), MinValueValidator(100000)])
receiver_fullname = models.CharField(default=None, blank=False, max_length=150)
receiver_adress = models.CharField(default=None, blank=False, max_length=400)
sender = models.ForeignKey(Dostavshik, on_delete=models.CASCADE, default=None, blank=False)

def __str__(self):
return str(self.id)


forms.py



class SrdbForm(forms.Form):
send_date = forms.DateField(widget=forms.DateInput(attrs={'type': 'date'}), label='Дата Отправки')
send_weight = forms.IntegerField(initial=0, validators=[MaxValueValidator(10000), MinValueValidator(100)],
label='Отправленный Вес (граммы)')
track_code = forms.CharField(max_length=20,
widget=forms.TextInput(attrs={'placeholder': 'Код Отслеживания Посылки'}),
label='Трек Код')
send_index = forms.IntegerField(validators=[MaxValueValidator(999999), MinValueValidator(100000)],
widget=forms.TextInput(attrs={'placeholder': 'Индекс Почты Отправления'}),
label='Индекc Отправления')
sender_fullname = forms.CharField(max_length=150,
widget=forms.TextInput(attrs={'placeholder': 'Отправитель'}),
label='ФИО отправителя')
sender_dob = forms.DateField(widget=forms.DateInput(attrs={'type': 'date'}), label='Дата Рождения Отправителя')
sender_adress = forms.CharField(max_length=200,
widget=forms.TextInput(attrs={'placeholder': 'Полный Адрес Отправителя'}),
label='Адрес отправителя')

# Получатель
receiver_index = forms.IntegerField(validators=[MaxValueValidator(999999), MinValueValidator(100000)],
widget=forms.TextInput(attrs={'placeholder': 'Индекс Почты Получения'}),
label='Индекс Получателя')
receiver_fullname = forms.CharField(max_length=100,
widget=forms.TextInput(attrs={'placeholder': 'Получатель'}),
label='ФИО Получателя')
receiver_adress = forms.CharField(max_length=200,
widget=forms.TextInput(attrs={'placeholder': 'Полный Адрес Получателя'}),
label='Адрес Проживания Получателя')
sender = forms.ModelChoiceField(queryset=Dostavshik.objects.all(),
label='Отправил Доставщик')


views.py



def srdb(request):
form_srdb = SrdbForm()
if request.method == 'POST':
form_srdb = SrdbForm(request.POST)
if form_srdb.is_valid():
Srdb.objects.create(**form_srdb.cleaned_data)
messages.success(request, 'Данные Успешно Сохранены')
context = {
'form_srdb': form_srdb
}
template = 'srdb.html'
return render(request, template, context)


After submit always have this error:




TypeError at /srdb/

'send_date' is an invalid keyword argument for this function











share|improve this question

























  • Is this how you intended the code?

    – Willem Van Onsem
    Jan 1 at 11:56











  • You need to show the full traceback. But you shouldn't be doing most of this. You should use a ModelForm instead of duplicating all the field definitions, and call form.save() instead of passing the cleaned data to the create method.

    – Daniel Roseman
    Jan 1 at 11:58













  • ok i will try but in modelform i have a problem with rendering , in my template {{ form.as_p }} work , but when i try to render field manualy like {{ form.send_date }} not work ... nothing shown..

    – Joby Joe
    Jan 1 at 12:30
















0















I am new to Python trying to make forms field and have a problem.
My forms shows correctly at html but when I am trying to submit data and save it to a database, but I have an error:




TypeError at /srdb/

'send_date' is an invalid keyword argument for this function




Here is my code:



models.py



class Srdb(models.Model):
send_date = models.DateField()
send_weight = models.IntegerField(default=0, validators=[MaxValueValidator(10000), MinValueValidator(100)])
track_code = models.CharField(default=None, blank=False, max_length=20)
send_index = models.IntegerField(default=None, blank=False,
validators=[MaxValueValidator(999999), MinValueValidator(100000)])
sender_fullname = models.CharField(default=None, blank=False, max_length=150)
sender_dob = models.DateField()
sender_adress = models.CharField(default=None, blank=False, max_length=400)

receiver_index = models.IntegerField(default=None, blank=False,
validators=[MaxValueValidator(999999), MinValueValidator(100000)])
receiver_fullname = models.CharField(default=None, blank=False, max_length=150)
receiver_adress = models.CharField(default=None, blank=False, max_length=400)
sender = models.ForeignKey(Dostavshik, on_delete=models.CASCADE, default=None, blank=False)

def __str__(self):
return str(self.id)


forms.py



class SrdbForm(forms.Form):
send_date = forms.DateField(widget=forms.DateInput(attrs={'type': 'date'}), label='Дата Отправки')
send_weight = forms.IntegerField(initial=0, validators=[MaxValueValidator(10000), MinValueValidator(100)],
label='Отправленный Вес (граммы)')
track_code = forms.CharField(max_length=20,
widget=forms.TextInput(attrs={'placeholder': 'Код Отслеживания Посылки'}),
label='Трек Код')
send_index = forms.IntegerField(validators=[MaxValueValidator(999999), MinValueValidator(100000)],
widget=forms.TextInput(attrs={'placeholder': 'Индекс Почты Отправления'}),
label='Индекc Отправления')
sender_fullname = forms.CharField(max_length=150,
widget=forms.TextInput(attrs={'placeholder': 'Отправитель'}),
label='ФИО отправителя')
sender_dob = forms.DateField(widget=forms.DateInput(attrs={'type': 'date'}), label='Дата Рождения Отправителя')
sender_adress = forms.CharField(max_length=200,
widget=forms.TextInput(attrs={'placeholder': 'Полный Адрес Отправителя'}),
label='Адрес отправителя')

# Получатель
receiver_index = forms.IntegerField(validators=[MaxValueValidator(999999), MinValueValidator(100000)],
widget=forms.TextInput(attrs={'placeholder': 'Индекс Почты Получения'}),
label='Индекс Получателя')
receiver_fullname = forms.CharField(max_length=100,
widget=forms.TextInput(attrs={'placeholder': 'Получатель'}),
label='ФИО Получателя')
receiver_adress = forms.CharField(max_length=200,
widget=forms.TextInput(attrs={'placeholder': 'Полный Адрес Получателя'}),
label='Адрес Проживания Получателя')
sender = forms.ModelChoiceField(queryset=Dostavshik.objects.all(),
label='Отправил Доставщик')


views.py



def srdb(request):
form_srdb = SrdbForm()
if request.method == 'POST':
form_srdb = SrdbForm(request.POST)
if form_srdb.is_valid():
Srdb.objects.create(**form_srdb.cleaned_data)
messages.success(request, 'Данные Успешно Сохранены')
context = {
'form_srdb': form_srdb
}
template = 'srdb.html'
return render(request, template, context)


After submit always have this error:




TypeError at /srdb/

'send_date' is an invalid keyword argument for this function











share|improve this question

























  • Is this how you intended the code?

    – Willem Van Onsem
    Jan 1 at 11:56











  • You need to show the full traceback. But you shouldn't be doing most of this. You should use a ModelForm instead of duplicating all the field definitions, and call form.save() instead of passing the cleaned data to the create method.

    – Daniel Roseman
    Jan 1 at 11:58













  • ok i will try but in modelform i have a problem with rendering , in my template {{ form.as_p }} work , but when i try to render field manualy like {{ form.send_date }} not work ... nothing shown..

    – Joby Joe
    Jan 1 at 12:30














0












0








0








I am new to Python trying to make forms field and have a problem.
My forms shows correctly at html but when I am trying to submit data and save it to a database, but I have an error:




TypeError at /srdb/

'send_date' is an invalid keyword argument for this function




Here is my code:



models.py



class Srdb(models.Model):
send_date = models.DateField()
send_weight = models.IntegerField(default=0, validators=[MaxValueValidator(10000), MinValueValidator(100)])
track_code = models.CharField(default=None, blank=False, max_length=20)
send_index = models.IntegerField(default=None, blank=False,
validators=[MaxValueValidator(999999), MinValueValidator(100000)])
sender_fullname = models.CharField(default=None, blank=False, max_length=150)
sender_dob = models.DateField()
sender_adress = models.CharField(default=None, blank=False, max_length=400)

receiver_index = models.IntegerField(default=None, blank=False,
validators=[MaxValueValidator(999999), MinValueValidator(100000)])
receiver_fullname = models.CharField(default=None, blank=False, max_length=150)
receiver_adress = models.CharField(default=None, blank=False, max_length=400)
sender = models.ForeignKey(Dostavshik, on_delete=models.CASCADE, default=None, blank=False)

def __str__(self):
return str(self.id)


forms.py



class SrdbForm(forms.Form):
send_date = forms.DateField(widget=forms.DateInput(attrs={'type': 'date'}), label='Дата Отправки')
send_weight = forms.IntegerField(initial=0, validators=[MaxValueValidator(10000), MinValueValidator(100)],
label='Отправленный Вес (граммы)')
track_code = forms.CharField(max_length=20,
widget=forms.TextInput(attrs={'placeholder': 'Код Отслеживания Посылки'}),
label='Трек Код')
send_index = forms.IntegerField(validators=[MaxValueValidator(999999), MinValueValidator(100000)],
widget=forms.TextInput(attrs={'placeholder': 'Индекс Почты Отправления'}),
label='Индекc Отправления')
sender_fullname = forms.CharField(max_length=150,
widget=forms.TextInput(attrs={'placeholder': 'Отправитель'}),
label='ФИО отправителя')
sender_dob = forms.DateField(widget=forms.DateInput(attrs={'type': 'date'}), label='Дата Рождения Отправителя')
sender_adress = forms.CharField(max_length=200,
widget=forms.TextInput(attrs={'placeholder': 'Полный Адрес Отправителя'}),
label='Адрес отправителя')

# Получатель
receiver_index = forms.IntegerField(validators=[MaxValueValidator(999999), MinValueValidator(100000)],
widget=forms.TextInput(attrs={'placeholder': 'Индекс Почты Получения'}),
label='Индекс Получателя')
receiver_fullname = forms.CharField(max_length=100,
widget=forms.TextInput(attrs={'placeholder': 'Получатель'}),
label='ФИО Получателя')
receiver_adress = forms.CharField(max_length=200,
widget=forms.TextInput(attrs={'placeholder': 'Полный Адрес Получателя'}),
label='Адрес Проживания Получателя')
sender = forms.ModelChoiceField(queryset=Dostavshik.objects.all(),
label='Отправил Доставщик')


views.py



def srdb(request):
form_srdb = SrdbForm()
if request.method == 'POST':
form_srdb = SrdbForm(request.POST)
if form_srdb.is_valid():
Srdb.objects.create(**form_srdb.cleaned_data)
messages.success(request, 'Данные Успешно Сохранены')
context = {
'form_srdb': form_srdb
}
template = 'srdb.html'
return render(request, template, context)


After submit always have this error:




TypeError at /srdb/

'send_date' is an invalid keyword argument for this function











share|improve this question
















I am new to Python trying to make forms field and have a problem.
My forms shows correctly at html but when I am trying to submit data and save it to a database, but I have an error:




TypeError at /srdb/

'send_date' is an invalid keyword argument for this function




Here is my code:



models.py



class Srdb(models.Model):
send_date = models.DateField()
send_weight = models.IntegerField(default=0, validators=[MaxValueValidator(10000), MinValueValidator(100)])
track_code = models.CharField(default=None, blank=False, max_length=20)
send_index = models.IntegerField(default=None, blank=False,
validators=[MaxValueValidator(999999), MinValueValidator(100000)])
sender_fullname = models.CharField(default=None, blank=False, max_length=150)
sender_dob = models.DateField()
sender_adress = models.CharField(default=None, blank=False, max_length=400)

receiver_index = models.IntegerField(default=None, blank=False,
validators=[MaxValueValidator(999999), MinValueValidator(100000)])
receiver_fullname = models.CharField(default=None, blank=False, max_length=150)
receiver_adress = models.CharField(default=None, blank=False, max_length=400)
sender = models.ForeignKey(Dostavshik, on_delete=models.CASCADE, default=None, blank=False)

def __str__(self):
return str(self.id)


forms.py



class SrdbForm(forms.Form):
send_date = forms.DateField(widget=forms.DateInput(attrs={'type': 'date'}), label='Дата Отправки')
send_weight = forms.IntegerField(initial=0, validators=[MaxValueValidator(10000), MinValueValidator(100)],
label='Отправленный Вес (граммы)')
track_code = forms.CharField(max_length=20,
widget=forms.TextInput(attrs={'placeholder': 'Код Отслеживания Посылки'}),
label='Трек Код')
send_index = forms.IntegerField(validators=[MaxValueValidator(999999), MinValueValidator(100000)],
widget=forms.TextInput(attrs={'placeholder': 'Индекс Почты Отправления'}),
label='Индекc Отправления')
sender_fullname = forms.CharField(max_length=150,
widget=forms.TextInput(attrs={'placeholder': 'Отправитель'}),
label='ФИО отправителя')
sender_dob = forms.DateField(widget=forms.DateInput(attrs={'type': 'date'}), label='Дата Рождения Отправителя')
sender_adress = forms.CharField(max_length=200,
widget=forms.TextInput(attrs={'placeholder': 'Полный Адрес Отправителя'}),
label='Адрес отправителя')

# Получатель
receiver_index = forms.IntegerField(validators=[MaxValueValidator(999999), MinValueValidator(100000)],
widget=forms.TextInput(attrs={'placeholder': 'Индекс Почты Получения'}),
label='Индекс Получателя')
receiver_fullname = forms.CharField(max_length=100,
widget=forms.TextInput(attrs={'placeholder': 'Получатель'}),
label='ФИО Получателя')
receiver_adress = forms.CharField(max_length=200,
widget=forms.TextInput(attrs={'placeholder': 'Полный Адрес Получателя'}),
label='Адрес Проживания Получателя')
sender = forms.ModelChoiceField(queryset=Dostavshik.objects.all(),
label='Отправил Доставщик')


views.py



def srdb(request):
form_srdb = SrdbForm()
if request.method == 'POST':
form_srdb = SrdbForm(request.POST)
if form_srdb.is_valid():
Srdb.objects.create(**form_srdb.cleaned_data)
messages.success(request, 'Данные Успешно Сохранены')
context = {
'form_srdb': form_srdb
}
template = 'srdb.html'
return render(request, template, context)


After submit always have this error:




TypeError at /srdb/

'send_date' is an invalid keyword argument for this function








django forms model django-forms typeerror






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 1 at 11:59









Brian Tompsett - 汤莱恩

4,2321338102




4,2321338102










asked Jan 1 at 11:50









Joby JoeJoby Joe

1




1













  • Is this how you intended the code?

    – Willem Van Onsem
    Jan 1 at 11:56











  • You need to show the full traceback. But you shouldn't be doing most of this. You should use a ModelForm instead of duplicating all the field definitions, and call form.save() instead of passing the cleaned data to the create method.

    – Daniel Roseman
    Jan 1 at 11:58













  • ok i will try but in modelform i have a problem with rendering , in my template {{ form.as_p }} work , but when i try to render field manualy like {{ form.send_date }} not work ... nothing shown..

    – Joby Joe
    Jan 1 at 12:30



















  • Is this how you intended the code?

    – Willem Van Onsem
    Jan 1 at 11:56











  • You need to show the full traceback. But you shouldn't be doing most of this. You should use a ModelForm instead of duplicating all the field definitions, and call form.save() instead of passing the cleaned data to the create method.

    – Daniel Roseman
    Jan 1 at 11:58













  • ok i will try but in modelform i have a problem with rendering , in my template {{ form.as_p }} work , but when i try to render field manualy like {{ form.send_date }} not work ... nothing shown..

    – Joby Joe
    Jan 1 at 12:30

















Is this how you intended the code?

– Willem Van Onsem
Jan 1 at 11:56





Is this how you intended the code?

– Willem Van Onsem
Jan 1 at 11:56













You need to show the full traceback. But you shouldn't be doing most of this. You should use a ModelForm instead of duplicating all the field definitions, and call form.save() instead of passing the cleaned data to the create method.

– Daniel Roseman
Jan 1 at 11:58







You need to show the full traceback. But you shouldn't be doing most of this. You should use a ModelForm instead of duplicating all the field definitions, and call form.save() instead of passing the cleaned data to the create method.

– Daniel Roseman
Jan 1 at 11:58















ok i will try but in modelform i have a problem with rendering , in my template {{ form.as_p }} work , but when i try to render field manualy like {{ form.send_date }} not work ... nothing shown..

– Joby Joe
Jan 1 at 12:30





ok i will try but in modelform i have a problem with rendering , in my template {{ form.as_p }} work , but when i try to render field manualy like {{ form.send_date }} not work ... nothing shown..

– Joby Joe
Jan 1 at 12:30












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53995179%2ftypeerror-an-invalid-keyword-argument-for-this-function%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53995179%2ftypeerror-an-invalid-keyword-argument-for-this-function%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

android studio warns about leanback feature tag usage required on manifest while using Unity exported app?

SQL update select statement

'app-layout' is not a known element: how to share Component with different Modules