I am making models for my django blog application. But upon running python manage.py makemigrations blog, I get this error message:
SystemCheckError: System check identified some issues:
ERRORS:
blog.Post: (models.E014) 'ordering' must be a tuple or list (even if you want to order by only one field).
Here is my models.py file:
from django.db import models
from django.utils import timezone
from django.contrib.auth.models import User
class Post(models.Model):
STATUS_CHOICES = (
('draft','Draft'),
('published','Published')
)
title = models.CharField(max_length=250)
slug = models.SlugField(max_length=250,unique_for_date='publish')
author = models.ForeignKey(User,on_delete=models.CASCADE,related_name='blog_posts')
body = models.TextField()
publish = models.DateTimeField(default=timezone.now)
created = models.DateTimeField(auto_now_add=True)
updated = models.DateTimeField(auto_now=True)
status = models.CharField(max_length=10,choices=STATUS_CHOICES,default='draft')
class Meta:
ordering = ('-publish')
def __str__(self):
return self.title
The error says that my ordering should be a list or tuple. But it already is. I can't understand this error. Can someone please help me out? Thanks in advance