This is my models.py:
from django.contrib.flatpages.models import FlatPage
class FlatPageManager(models.Manager):
def search(self, query=None):
qs = self.get_queryset()
if query is not None:
or_lookup = (Q(title__icontains=query) |
Q(content__icontains=query)
)
qs = qs.filter(or_lookup).distinct()
return qs
class MyFlatPage(FlatPage):
class Meta:
proxy = True
published = models.DateTimeField() # <- this is the field I want to add
objects = FlatPageManager()
When I do makemigrations
I get this error:
./manage.py makemigrations
SystemCheckError: System check identified some issues:
ERRORS:
?: (models.E017) Proxy model 'MyFlatPage' contains model fields.
What am I doing wrong? All I want to do is to add a published
field so that I can display the post only on a certain date in the future.
Edit
I have now learned that proxy models do not accept new fields by definition. My next question is then: how can I 'convert' my existing proxy model into something else (without losing my existing data of course) so that I can have an extra published
field?