I am new to Django
So I have this model for a page and it looks like this:
from django.db import models
from django.utils import timezone
# Create your models here.
class Page(models.Model):
title = models.CharField(max_length=200, unique=True, editable=True)
body = models.TextField(editable=True, help_text='This is the body of the page')
url = models.CharField(max_length=128, unique=True, default=Page.title)
date_created = models.DateTimeField(auto_now_add=True)
published = models.BooleanField(default=True)
class Meta:
ordering = ['date_created']
verbose_name_plural = "pages"
def __str__(self):
return self.title
When I run the server it tells me Page in not defined. How can Page not be defined? How do I then make the Page.title the default if no URL is entered?
Help is appreciated thanks