'Pyrhon and Django AttributeError ".save"
The propelem is I'm getting an error at this line:
s_lance.seve()
It's an Attribute error Views.py
def f(request):
if request.method == "POST":
titulo = request.POST['titulo']
user = request.user
descricao = request.POST['descricao']
s_lance = Produto(titulo = titulo, user = user, descricao = descricao)
s_lance.seve()
models.py
class Produto(models.Model):
titulo = models.CharField(max_length=25)
descricao = models.CharField(max_length=200)
user = models.ForeignKey(User, on_delete=models.CASCADE, related_name="lista", default=None)
I expected that values would be saved. However, I got this AttributeError 
Solution 1:[1]
it's .save()
And you can also use: s_lance = Produto.objects.create(titulo=titulo, user=user, descricao=descricao)
https://docs.djangoproject.com/en/4.0/ref/models/querysets/#django.db.models.query.QuerySet.create
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Luid Duarte |
