Я получаю сообщение об ошибке, когда пытаюсь получить данные из почтового запроса. Я пытаюсь создать пользовательскую модель (кроме встроенной может быть любая модель с 3 входами)
File "C:\Users\o00489658\AppData\Local\Continuum\anaconda3\lib\site-packages\django\contrib\staticf
return self.application(environ, start_response)
File "C:\Users\o00489658\AppData\Local\Continuum\anaconda3\lib\site-packages\django\core\handlers\w
response = self.get_response(request)
File "C:\Users\o00489658\AppData\Local\Continuum\anaconda3\lib\site-packages\django\core\handlers\b
response = self._middleware_chain(request)
File "C:\Users\o00489658\AppData\Local\Continuum\anaconda3\lib\site-packages\django\core\handlers\e
response = response_for_exception(request, exc)
File "C:\Users\o00489658\AppData\Local\Continuum\anaconda3\lib\site-packages\django\core\handlers\e
response = handle_uncaught_exception(request, get_resolver(get_urlconf()), sys.exc_info())
File "C:\Users\o00489658\AppData\Local\Continuum\anaconda3\lib\site-packages\django\core\handlers\e
return debug.technical_500_response(request, *exc_info)
File "C:\Users\o00489658\AppData\Local\Continuum\anaconda3\lib\site-packages\django\views\debug.py"
html = reporter.get_traceback_html()
File "C:\Users\o00489658\AppData\Local\Continuum\anaconda3\lib\site-packages\django\views\debug.py"
t = DEBUG_ENGINE.from_string(fh.read())
UnicodeDecodeError: 'gbk' codec can't decode byte 0xa6 in position 9737: illegal multibyte sequence
my models.py
from django.db import models
class kullanici(models.Model):
id=models.IntegerField(unique=True,primary_key=True)
Name=models.CharField(max_length=128)
LastName=models.CharField(max_length=128)
def __str__(self):
return self.id+' '+(self.Name)+' '+(self.LastName)
вид
from django.shortcuts import render
from django.http import HttpResponse
from myapp import forms
from myapp.forms import UsernameForm
def homepage(request):
mydict ={'inserted':'inserted via django '}
return render(request,"Linked_page.html",context=mydict)
def secondpage(request):
form = forms.UsernameForm()
form2 =UsernameForm(data=request.POST)
if request.method=='POST':
form=forms.UsernameForm(request.POST)
print('valid as in entry standard')
print(form)
form2.save()
return render(request,'onyuz.html',{'form':form})
def Users(request):
userlist=kullanici.objects.order_by('id')
mydict ={'access_records':userlist}
return render(request,"onyuzmodetrator.html",context=mydict)
форма
from django import forms
from myapp.models import kullanici
class UsernameForm(forms.Form):
Name=forms.CharField()
LastName=forms.CharField()
id=forms.IntegerField()
class Meta():
model=kullanici
fields='__all__'
html: {% load static%} вверху
<form class="" method="POST">
{{form}}
{% csrf_token %}
<input type="submit" name="" placeholder="Submit">
</form>