Answer the question
In order to leave comments, you need to log in
How to properly return data from the model?
There is a model:
class Post(models.Model):
post = models.CharField(max_length=500)
user = models.ForeignKey(User)
created = models.DateTimeField(auto_now_add=True)
updated = models.DateTimeField(auto_now=True)
user_pk = models.IntegerField(default=0)
user_send = models.IntegerField(default=0)
def __str__(self):
return self.post
Answer the question
In order to leave comments, you need to log in
The model is the data.
last_post = Post.objects.last()
print(last_post.created)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question