Django Output Prediction Medium +20 XP
Model Meta Ordering
In what order are posts returned by default?
DjangoRead-only
class Post(models.Model):
class Meta:
ordering = ["-created_at"]What is the output?
Show answer and explanation
Answer: Newest first
ordering = ["-created_at"] means sort by created_at descending (the - prefix means reverse/descending order).
Hint: What does the - prefix before a field mean?
What this challenge tests
Output Prediction in Django: models, meta.