【发布时间】:2022-01-13 21:07:24
【问题描述】:
我必须发布一些对象的内容,但我无法从这些对象中获取这些内容。 任何帮助将不胜感激。
from django.shortcuts import render, redirect
from cadastro.forms import CadastroForm
import requests
from . import models
def cadastro_usuario(request):
data = {}
data['form'] = CadastroForm()
return render(request, 'cadastro.html', data)
def create(request):
form = CadastroForm(request.POST or None)
user_name = models.Cadastro_alunos.user_name
user_cpf = models.Cadastro_alunos.user_cpf
user_password = models.Cadastro_alunos.user_password
user_genre = models.Cadastro_alunos.user_genre
user_email = models.Cadastro_alunos.user_email
dados_obrigatorios = {'token': 'xxxxxxxxxxxxxxxxxxxx',
'course_id': '1',
'course_plan': '1',
'user_name': user_name,
'user_cpf': user_cpf,
'course_type': '4',
'user_email': user_email,
'user_password': user_password,
'user_genre': user_genre}
print(dados_obrigatorios)
try:
form.save()
y = requests.post('https://www.iped.com.br/api/user/set-registration', data=dados_obrigatorios)
print(y.json())
except Exception as e:
print(e)
return redirect('https:/')
【问题讨论】:
标签: python-3.x django django-models