0
from django.db import models
class Topic(models.Model):
text = models.CharField(max_length=200)
date_added = models.DateTimeField(auto_now_add=True)
def __str__(self):
return self.text
class Entry(models.Model):
topic = models.ForeignKey(Topic, on_delete=models.PROTECT)
text = models.TextField()
date_added = models.DateTimeField(auto_now_add=True)
class Meta:
verbose_name_plural = 'entries'
def __str__(self):
return self.text[:50] + "..."
For me it was okay I had my template that made the user write a topic and he could put a subject related to it as in the image of my admin page to follow:
But when saving my text there was an error that I don’t understand why...
Does not print the error, but the message.
– BrunoVdutra
You didn’t create Migration...
python manage.py makemigrations
afterwardpython manage.py migrate
– Ricardo
created yes...it even made a file in Migrations folder:
– user174446