Hi,
I have create a model
Models.py
from django.db import models
import datetime
from django.utils import timezone
class Question(models.Model):
question_text = models.CharField(max_length=200)
pub_date = models.DateTimeField('date published')
def __str__(self):
return self.question_text
def was_published_recently(self):
return self.pub_date >= timezone.now() - datetime.timedelta(days=1)
using this model table created in database. I am creating REST API . I am
passing in request body
{
"question": { "question_text":"Some question?"
"pub_date":timezone.now()
}
}
I am getting this code, but how to save that data in existing model. So
that I can save that info into database.
i.e. want to save above data question object.
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/9fdae6df-dd1c-4229-b6eb-f8349528b1e0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.